Fix memory statistics on Alpine Linux (#93)
On Alpine Linux, free doesn't have a -t option. This commit removes it. Resolves hjelev/rpi-mqtt-monitor#91
This commit is contained in:
@@ -71,7 +71,7 @@ def check_voltage():
|
||||
|
||||
|
||||
def check_swap():
|
||||
full_cmd = "free -t |grep -i swap | awk 'NR == 1 {print $3/$2*100}'"
|
||||
full_cmd = "free | grep -i swap | awk 'NR == 1 {print $3/$2*100}'"
|
||||
swap = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
|
||||
swap = round(float(swap.decode("utf-8").replace(",", ".")), 1)
|
||||
|
||||
@@ -79,7 +79,7 @@ def check_swap():
|
||||
|
||||
|
||||
def check_memory():
|
||||
full_cmd = "free -t | awk 'NR == 2 {print $3/$2*100}'"
|
||||
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]
|
||||
memory = round(float(memory.decode("utf-8").replace(",", ".")))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user