Added memory usage percentage

This commit is contained in:
2021-03-14 13:04:06 +01:00
parent 800b661c3b
commit b380e9325e

View File

@@ -58,7 +58,7 @@ def update_keys(host, keys, host_length):
load, cpu_percent, ram_total, ram_free = parse_top_string(data) load, cpu_percent, ram_total, ram_free = parse_top_string(data)
print(('' + host).ljust(host_length + 5) + load + ' (' + '{:3.1f}'.format(cpu_percent).rjust(5) + '%) ' + '{:3.1f}'.format(ram_total - ram_free).rjust(5) + ' / ' + '{:3.1f}'.format(ram_total).rjust(5) + ' GiB') print(('' + host).ljust(host_length + 5) + load + ' (' + '{:3.1f}'.format(cpu_percent).rjust(5) + '%) ' + '{:3.1f}'.format(ram_total - ram_free).rjust(5) + ' / ' + '{:3.1f}'.format(ram_total).rjust(5) + ' GiB (' + '{:3.1f}'.format((ram_total - ram_free) / ram_total * 100).rjust(5) + '%)')
except: except:
print('' + host) print('' + host)
@@ -75,7 +75,7 @@ def main():
for key in config['keys']: for key in config['keys']:
keys.append(key['key']) keys.append(key['key'])
print('Host'.center(host_length + 3) + ' ' + 'Load'.center(25) + ' ' + 'Ram Usage'.center(17)) print('Host'.center(host_length + 3) + ' ' + 'Load'.center(25) + ' ' + 'Ram Usage'.center(26))
for host in config['hosts']: for host in config['hosts']:
try: try: