修复 busybox free -m 无法正常获取内存大小的问题

Signed-off-by: xiaofan <xfan1024@live.com>
pull/652/head
xiaofan 2023-12-26 10:47:21 +08:00
parent 4666795a28
commit b7293143ff
1 changed files with 2 additions and 2 deletions

View File

@ -240,9 +240,9 @@ def fetch_host_extend(ssh):
else:
response['memory'] = round(int(size) / 1024, 0)
if 'memory' not in response:
code, out = ssh.exec_command_raw("free -m | awk 'NR==2{print $2}'")
code, out = ssh.exec_command_raw("cat /proc/meminfo | grep 'MemTotal' | awk '{print $2}'")
if code == 0:
response['memory'] = math.ceil(int(out) / 1024)
response['memory'] = math.ceil(int(out) / 1024 / 1024)
response['public_ip_address'] = list(public_ip_address)
response['private_ip_address'] = list(private_ip_address)