Skip to content

Commit 99c0043

Browse files
authored
Merge pull request #652 from xfan1024/3.0
以兼容性更好的方式获取内存大小
2 parents 4666795 + b729314 commit 99c0043

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spug_api/apps/host/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ def fetch_host_extend(ssh):
240240
else:
241241
response['memory'] = round(int(size) / 1024, 0)
242242
if 'memory' not in response:
243-
code, out = ssh.exec_command_raw("free -m | awk 'NR==2{print $2}'")
243+
code, out = ssh.exec_command_raw("cat /proc/meminfo | grep 'MemTotal' | awk '{print $2}'")
244244
if code == 0:
245-
response['memory'] = math.ceil(int(out) / 1024)
245+
response['memory'] = math.ceil(int(out) / 1024 / 1024)
246246

247247
response['public_ip_address'] = list(public_ip_address)
248248
response['private_ip_address'] = list(private_ip_address)

0 commit comments

Comments
 (0)