Small optimization

This commit is contained in:
2021-03-14 14:33:39 +01:00
parent b380e9325e
commit 306611a85e

View File

@@ -57,8 +57,9 @@ def update_keys(host, keys, host_length):
client.close() client.close()
load, cpu_percent, ram_total, ram_free = parse_top_string(data) load, cpu_percent, ram_total, ram_free = parse_top_string(data)
ram_used = ram_total - ram_free
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) + '%)') print(('' + host).ljust(host_length + 5) + load + ' (' + '{:3.1f}'.format(cpu_percent).rjust(5) + '%) ' + '{:3.1f}'.format(ram_used).rjust(5) + ' / ' + '{:3.1f}'.format(ram_total).rjust(5) + ' GiB (' + '{:3.1f}'.format(ram_used / ram_total * 100).rjust(5) + '%)')
except: except:
print('' + host) print('' + host)