Changed method for obtaining memory info

This commit is contained in:
Thomas Williams 2024-06-29 17:59:54 +01:00
parent 66c31c6ff8
commit 839c36bbf7
Signed by: thomas
GPG key ID: EB8F975CF60BCBFF

View file

@ -60,9 +60,7 @@ def monitorHost(stop_event):
load1, load5, load15 = psutil.getloadavg() # this takes time to warm up if not running script on *nix load1, load5, load15 = psutil.getloadavg() # this takes time to warm up if not running script on *nix
loadavg = round((load1/os.cpu_count()) * 100, 2) loadavg = round((load1/os.cpu_count()) * 100, 2)
total_memory, used_memory, free_memory = map( memory = psutil.virtual_memory().percent
int, os.popen('free -t -m').readlines()[-1].split()[1:])
memory = round((used_memory/total_memory) * 100, 2)
print("CPU %: " + str(loadavg)) print("CPU %: " + str(loadavg))
print("Memory %: " + str(memory)) print("Memory %: " + str(memory))