From b380e9325eb79192e1ef6451e2589a3ed49f5712 Mon Sep 17 00:00:00 2001 From: Tobias Schneider Date: Sun, 14 Mar 2021 13:04:06 +0100 Subject: [PATCH] Added memory usage percentage --- monitor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index 762197b..7c09fc0 100755 --- a/monitor.py +++ b/monitor.py @@ -58,7 +58,7 @@ def update_keys(host, keys, host_length): 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: print('❌ ' + host) @@ -75,7 +75,7 @@ def main(): for key in config['keys']: 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']: try: