Remote RPI system monitor

An iOS app PiHelper can ssh in to my pi zero2 and show temps, cup, memory etc. I want to have a Lovelace card on my Pi4 that is running Only Hassio to report what this iOS app is doing.

I’m missing something as to what to install where.

Both are headless and Pi4 only controlled by Hassio and terminal plug-in, Pi zero2w is only running Octopi.

That’s why I asked as perhaps because of what the pi zero2 is running etc instructions are different.

I’m asking for help.

Is octopi based on debian/rapsbian?

OK answered my own question, so the command should just work.

When you log into the pi zero what happens when you run the first command given in the instructions:

git clone https://github.com/Sennevds/system_sensors.git

Soon the Pi zero 2 I got as far as config Mqtt. Not sure what to fill in. Also does the “mqtt:
discovery: true
discovery_prefix: homeassistant” get placed as a line in the Hassio config on Pi4?

You need an mqtt server (broker) on the pi4. Looks like you have installed the addon.

Now on the pi4 hass machine set up a user and password. That username and password are what you put in the pi zero as user and password. The hostname is the ip of the pi4 hass machine where the broker is running.

The yaml for the broker is not needed for the addon broker.

Client id?

For user are u saying to make a new Hassio user?
Sometimes I surprise myself on setting things up like My complete Hassio with all automations and then this block!
I went thropugh the install opn the Pi zero via SSh but Im stuck on EXACTLY what files go where.
What config/py file gets edited and goes where and I do have the Mqtt setup as I have my Ring Alram etc setup through that. Cant remeber Hhow I een accom;ished that to be honest.

Ok, I think I figured it out:

QUESTION: When I run teh script to get it to connect to MQTT broker, do I have to always leave that terminal window open and running?

I want connecting as i did not have proper MQTT credentials (uer/PW) to connect. I used the one I had in Hassio for MQTT and connected.
Now I see the sensors.
Thanks for getting me going.

When I ran the scripts I figured you the error messages…

Please if possible for the settings.yaml, I didint know what device id was and left it as it was in file.
Now I see my sensors labeled “test” so that answers my question but maybe others may benefit a wiki in “stupid lingo” what each of the “required” parameters mean.

Can you post a formated YAMl for your lovelace cards?

Thanks again!!!

The example yaml for the lovelace cards are at the bottom of the github page:

No, you can run it from systemd, it is the final step there, number 7. This will start the script and run it in the background.

Hmm. I’m still struggling with the under voltage sensor. I see this in the MQTT broker:

{
  "temperature": "33.2",
  "disk_use": "22.2",
  "memory_use": "35.2",
  "cpu_usage": "8.3",
  "net_tx": "0.15",
  "net_rx": "0.00",
  "swap_usage": "0.0",
  "power_status": "False",
  "last_boot": "2022-02-04T19:23:03+11:00",
  "updates": "0"
}

Yet the sensor state remains unknown.

Aha found the problem. The mqtt state payload sends False or True but the sensor is of device type problem so it should send on or off. I will fix it

1 Like

Just pushed an update. Power status is fixed + minor fix for cpu temp. Apparently the key can differ to get the cpu temp:

t = psutil.sensors_temperatures()
        for x in ['cpu-thermal', 'cpu_thermal']:
            if x in t:
                temp = t[x][0].current
                break

That was quick. Thanks!

Just checking that this is the correct procedure to update (as the requirements have not changed):

cd system_sensors
git pull
sudo apt-get install python3-apt
1 Like

Check. Normally you shouldn’t install python3-apt again if you already installed it

1 Like

Screenshot 2022-02-04 at 23-18-34 Administration – Home Assistant

1 Like

Hello All looking for some help
I think that I have all the items installed correctly, and I set up my settings.yaml starting from the settings_example.yaml.
But when I try and execute “python3 src/system_sensors.py src/settings.yaml” these are the errors that I get.
Any help would be wonderful, thank you.

pi@vpnpi:~/system_sensors $ python3 src/system_sensors.py src/settings.yaml
Traceback (most recent call last):
  File "/home/pi/system_sensors/src/system_sensors.py", line 215, in <module>
    mqttClient.connect(settings['mqtt']['hostname'], settings['mqtt']['port'])
  File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1115, in reconnect
    return self._send_connect(self._keepalive)
  File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2611, in _send_connect
    1 + 2 + 2 + len(self._client_id)
TypeError: object of type 'int' has no len()
pi@vpnpi:~/system_sensors $

Could you check the value in the settings.yaml for the port of mqtt. I think there’s something wrong with that

Sennevds Thank You for the reply.
Sorry for not posting back sooner.
Yes, I did find that to be the case.
The IP address was all hosed up.
Once I fixed this, it all work just fine.
So it’s up and running now.

Hello.

Just decided to give your script a try in one of my RPis and I have noticed that the MQTT server is being spammed with too many messages, I supposed due to this:

It seems to be sending messages every 2 seconds, when my config states to send updates every 5 minutes:

mqtt:
  hostname: *** redacted ***
  port: 1883 #defaults to 1883
  user: *** redacted ***
  password: *** redacted ***
deviceName: Multipurpose
client_id: multipurpose-pi
timezone: *** redacted ***
update_interval: 300 #Defaults to 60
sensors:
  temperature: true
  clock_speed: true
  disk_use: true
  memory_use: true
  cpu_usage: true
  load_1m: true
  load_5m: true
  load_15m: true
  net_tx: true
  net_rx: true
  swap_usage: true
  power_status: true
  last_boot: true
  hostname: false
  host_ip: false
  host_os: true
  host_arch: true
  last_message: true
  updates: true
  wifi_strength: false
  wifi_ssid: false
  external_drives:
    # Only add mounted drives here, e.g.:
    # Drive1: /media/storage

What can be done to avoid this from happening, or at least reduce the periodicity of these messages?

Thanks in advance and kind regards.

For some reason your home assistant instance sends a online message every x seconds. Everytime home assistant sends this message the script will send the current values so ha doesn’t show unknown values. Your issue is with ha and not with the script I think.

I suppose you’re using the birth message sent from HA to MQTT broker (installed as add-on in HA), but as far as I can see from my logs, I don’t see it being sent every x seconds (although it is sent as retained).

As per documentation:
Birth message - The birth message will be sent each time Home Assistant (re)connects to the MQTT broker.

Any idea on how to troubleshoot this?

Thanks in advance and kind regards.