Merge pull request #652 from xfan1024/3.0

以兼容性更好的方式获取内存大小
pull/659/head
vapao 2024-02-27 00:14:50 +08:00 committed by GitHub
commit 99c00433dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -240,9 +240,9 @@ def fetch_host_extend(ssh):
else: else:
response['memory'] = round(int(size) / 1024, 0) response['memory'] = round(int(size) / 1024, 0)
if 'memory' not in response: 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: 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['public_ip_address'] = list(public_ip_address)
response['private_ip_address'] = list(private_ip_address) response['private_ip_address'] = list(private_ip_address)