set memory to 0 if no data is available (#134)

This commit is contained in:
Masoko
2024-10-18 15:08:50 +03:00
committed by GitHub
parent e43428f8fd
commit 0e213c9797

View File

@@ -84,10 +84,13 @@ def check_swap():
def check_memory():
full_cmd = "free | grep -i mem | awk 'NR == 1 {print $3/$2*100}'"
memory = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
if memory == '':
if not memory:
full_cmd = "free | grep -i speicher | awk 'NR == 1 {print $3/$2*100}'"
memory = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
if memory:
memory = round(float(memory.decode("utf-8").replace(",", ".")))
else:
memory = 0
return memory