U 优化获取主机扩展信息

pull/418/head
vapao 2021-12-09 11:06:14 +08:00
parent 91569b6a35
commit f519942ffa
1 changed files with 6 additions and 2 deletions

View File

@ -216,9 +216,13 @@ def fetch_host_extend(ssh):
code, out = ssh.exec_command_raw('lsblk -dbn -o SIZE -e 11 2> /dev/null') code, out = ssh.exec_command_raw('lsblk -dbn -o SIZE -e 11 2> /dev/null')
if code == 0: if code == 0:
for item in out.strip().splitlines()[:10]: disks = []
for item in out.strip().splitlines():
item = item.strip() item = item.strip()
response['disk'].append(math.ceil(int(item) / 1024 / 1024 / 1024)) size = math.ceil(int(item) / 1024 / 1024 / 1024)
if size > 10:
disks.append(size)
response['disk'] = disks[:10]
code, out = ssh.exec_command_raw("dmidecode -t 17 | grep -E 'Size: [0-9]+' | awk '{s+=$2} END {print s,$3}'") code, out = ssh.exec_command_raw("dmidecode -t 17 | grep -E 'Size: [0-9]+' | awk '{s+=$2} END {print s,$3}'")
if code == 0: if code == 0: