Remote RPI system monitor

Will do. I’ll see if I can get the swap use sensor working and add that too.

Spoke too soon I cant get it working as a service:

pi@gpio_mqtt_bridge_1:~/system_sensors $ sudo systemctl status system_sensor
● system_sensor.service - System Sensor service
   Loaded: loaded (/etc/systemd/system/system_sensor.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-08-15 16:45:38 AEST; 24min ago
  Process: 790 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/ (code=exited, status=1/FAILURE)
 Main PID: 790 (code=exited, status=1/FAILURE)

Aug 15 16:45:37 gpio_mqtt_bridge_1 systemd[1]: Started System Sensor service.
Aug 15 16:45:38 gpio_mqtt_bridge_1 python3[790]: Traceback (most recent call last):
Aug 15 16:45:38 gpio_mqtt_bridge_1 python3[790]:   File "/home/pi/system_sensors/src/", line 4, in <module>
Aug 15 16:45:38 gpio_mqtt_bridge_1 python3[790]:     import psutil
Aug 15 16:45:38 gpio_mqtt_bridge_1 python3[790]: ImportError: No module named 'psutil'
Aug 15 16:45:38 gpio_mqtt_bridge_1 systemd[1]: system_sensor.service: Main process exited, code=exited, status=1/FAILURE
Aug 15 16:45:38 gpio_mqtt_bridge_1 systemd[1]: system_sensor.service: Unit entered failed state.
Aug 15 16:45:38 gpio_mqtt_bridge_1 systemd[1]: system_sensor.service: Failed with result 'exit-code'.

Why cant it find psutil?

pi@gpio_mqtt_bridge_1:~/system_sensors $ pip3 install -r requirements.txt
Collecting paho-mqtt==1.4.0 (from -r requirements.txt (line 1))
  Using cached
Collecting psutil==5.6.3 (from -r requirements.txt (line 2))
  Using cached
Collecting pytz==2019.2 (from -r requirements.txt (line 3))
  Using cached
Installing collected packages: paho-mqtt, psutil, pytz
Successfully installed paho-mqtt-1.4.0 psutil-5.6.3 pytz-2019.2
pi@gpio_mqtt_bridge_1:~/system_sensors $

Yeah I need to update the readme.
You have following options:

so do this?

sudo pip3 install -r requirements.txt

or change the service to start as your user:

Description=System Sensor service

ExecStart=/usr/bin/python3 /home/pi/sensors/


Change the [user] to your user(ex ‘pi’)

1 Like

I installed it as super user. Did the trick.

Ideally I would install it using virtualenv but I’m just not that confident in my linux skills.

Hmm. I can start the service manually but it fails after a reboot:

Aug 15 18:01:15 gpio_mqtt_bridge_2 python3[587]: OSError: [Errno 101] Network is unreachable

Looking for a way to make it wait…

Maybe I should update the code to check for internet. No internet => wait => try again

I have two remote pi’s. One is starting the service fine on boot the other not.

The start up from boot now seems to be much slower on both.

I notice that when I start the service manually on the on that fails it asks for the pi password.

The configuration of the services should be identical. Investigating…

EDIT: the execute file permissions had changed on for the faulty one.

EDIT2: still not starting (same error) and still asking for a password.

This looks awesome!! I’ve just started to look for a way to get some additional data across from my Pi, and since I can’t work out SSH keys from on docker (odd cause I got it working on everything else), using MQTT is something that I was looking at using.

I use the glances API. That way it’s not actually sending any info, and HA just grabs what I want it to when the scan interval tells it too.

I’ve updated the script so it includes unique_id and device information in the intial config message.
The state topics are changed so I don’t spam the homeassistant topic. All state topics are send on the system-sensors topic. If you update the script and let it run everything should be working fine.

I’ve also merged the change of @tom_l so it now includes the swap use!

Should I remove any retained messages in the broker before updating or will it use the same topics?

I don’t wwant to end up with a bunch of sensor…_2 sensors.

Normally only the configs are retained and these are not changed from topic. Hass reads the updated config and changes the entity to the new state topic.
I’ve restarted hass to let it detect the entities as a device

1 Like

Updated and see the devices in the entity registry now. :+1:

1 Like

Thanks for this -exactly what i was looking for!

I run HA in a Linux Container in Proxmox and have 8 or 9 other containers running various bits. I have amended your script to remove the RPI specific attributes and it works like a charm on my LXCs!



1 Like

Does anyone have any idea how to monitor the Ethernet throughput (Mb/s in & out) on a pi?

I’d like to add these sensors as well.

maybe with the following command:
But I think that’s only going to give 10/100/1000 not sure though

Hi together,

first of all thanks to @Sennevds for creating this python script :slight_smile: I really like to use it for monitoring my various PIs!

I created a containerised version of this script.

So you only need to run “docker-compose up” to run the script :slight_smile:

Forked Github Repo including Dockerfile and docker-compose:

Dockerhub Image:

Hope you don’t mind :wink:

1 Like

Super ofcourse I don’t mind. This moment I don’t use docker but i’m going to switch my hass installation because I’m still using hassbian!

I forgot about this. I did not get a throughput sensor working for anyone wondering.