From a64c63113d42e9eb3d5dea1ff2d0add9be16bd14 Mon Sep 17 00:00:00 2001 From: Masoko Date: Wed, 8 May 2024 18:53:03 +0300 Subject: [PATCH] Add support for systems with German language (#111) --- README.md | 8 ++++---- src/rpi-cpu2mqtt.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9a8b559..e727667 100644 --- a/README.md +++ b/README.md @@ -200,15 +200,15 @@ You need to edit the service file and update the path to the script and the user Then copy the service file to ```/etc/systemd/system/``` and enable it: ```bash -sudo cp rpi-cpu2mqtt.service /etc/systemd/system/ -sudo systemctl enable rpi-cpu2mqtt.service +sudo cp rpi-mqtt-monitor.service /etc/systemd/system/ +sudo systemctl enable rpi-mqtt-monitor.service ``` To test that the service is working you can run: ```bash -sudo service rpi-cpu2mqtt start -sudo service rpi-cpu2mqtt status +sudo service rpi-mqtt-monitor start +sudo service rpi-mqtt-monitor status ``` ## Schedule Raspberry Pi MQTT Monitor execution with a cron diff --git a/src/rpi-cpu2mqtt.py b/src/rpi-cpu2mqtt.py index 2fb5bab..a27a07f 100644 --- a/src/rpi-cpu2mqtt.py +++ b/src/rpi-cpu2mqtt.py @@ -81,6 +81,9 @@ 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 == '': + 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] memory = round(float(memory.decode("utf-8").replace(",", "."))) return memory