Git Product home page Git Product logo

rpi-mqtt-monitor's People

Contributors

ahti123 avatar cfenner avatar hjelev avatar j-broo avatar leaskovski avatar nivg1992 avatar olexs avatar pulpyyyy avatar randy3k avatar sunsided avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpi-mqtt-monitor's Issues

Entity update not working

Hi,
The update entity doesn't work. I'm in version 0.9.1 and it still tells me 0.8.9.
image
image
image

However, if I look at the information in rpi-mqtt-monitor, I am in version 0.9.1.
rpi-mqtt-monitor2

The update entity image is missing. If I connect to the image link, it tells me "Folder not found".
I'm using a local image in the meantime.

help troubleshoot: cpu temperature not available

Hi. I've installed the script on a Ubuntu 22.04 OS. The cpu temperature isn't available when I try running below cat. Any idea why it is not displaying?? I am using a Beelink mini pc.

ser@ser:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
ser@ser:~$ cat /sys/class/thermal/thermal_zone*/temp 2> /dev/null | sed 's/\(.\)..$//' | tail -n 1
ser@ser:~$ cat /sys/devices/virtual/thermal/thermal_zone0*/temp 2> /dev/null | sed 's/\(.\)..$//' | tail -n 1
ser@ser:~$ sudo systemctl status rpi-mqtt-monitor.service
● rpi-mqtt-monitor.service - System Sensors Monitor
 Loaded: loaded (/etc/systemd/system/rpi-mqtt-monitor.service; disabled; vendor preset: enabled)
 Active: active (running) since Tue 2024-02-13 07:56:53 JST; 46min ago
 Main PID: 58972 (python3)
 Tasks: 4 (limit: 15302)
 Memory: 22.5M
 CPU: 2.542s
 CGroup: /system.slice/rpi-mqtt-monitor.service
 └─58972 /usr/bin/python3 /srv/git/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py --service

Feb 13 07:56:53 ser systemd[1]: Started System Sensors Monitor.

Minor typo in documentation

The service examples in the Readme reference a service file called rpi-cpu2mqtt.service, however the filename in the distribution seems to have been changed to rpi-mqtt-monitor.service

Examples should read
sudo cp rpi-mqtt-monitor.service /etc/systemd/system/ ; sudo systemctl enable rpi-mqtt-monitor.service
and
sudo service rpi-mqtt-monitor start ; sudo service rpi-mqtt-monitor status
respectively

Division by Zero

Tried both manually installing and using the script. Fails to run with a divide by zero error. Thoughts?

awk: cmd. line:1: (FILENAME=- FNR=3) fatal: division by zero attempted
Traceback (most recent call last):
File "/home//rpi-cpu2mqtt.py", line 249, in
swap = check_swap()
File "/home/
/rpi-cpu2mqtt.py", line 51, in check_swap
swap = round(float(swap.decode("utf-8").replace(",", ".")), 1)
ValueError: could not convert string to float: ''

Unable to get it work on Ubuntu Server

Linux raspberrypi4 5.19.0-1009-raspi #16-Ubuntu SMP PREEMPT Thu Nov 24 13:38:20 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

``pi@raspberrypi4:~/rpi-mqtt-monitor/src$ /usr/bin/python3 /home/pi/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: division by zero attempted
Traceback (most recent call last):
File "/home/pi/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 318, in
swap = check_swap()
File "/home/pi/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 71, in check_swap
swap = round(float(swap.decode("utf-8").replace(",", ".")), 1)
ValueError: could not convert string to float: ''

Homeassistant Name convention

Hello,
i use your script with Home Assistant. It's working fine :)
But HA has a naming convention that the Hostname should not be in the Entity name.

suggestion:
provide an HA Version of your script and remove "hostname" from the Description lines.
data["name"] = hostname + " CPU Usage" ...
Thanks

Naming of MQTT Entities
https://rc.home-assistant.io/integrations/mqtt/

Warning Message in home-asssistant.log
[homeassistant.components.mqtt.mixins] MQTT entity name starts with the device name in your config {'state_topic': 'mqtt-monitor/pi-alarm/uptime_days', 'icon': 'mdi:calendar', 'name': 'pi-alarm Uptime', 'unique_id': 'pi-alarm_uptime_days', 'unit_of_measurement': 'days', 'device': {'identifiers': ['pi-alarm'], 'manufacturer': 'Raspberry Pi', 'model': 'Raspberry Pi 4 Model B Rev 1.2\x00', 'name': 'pi-alarm', 'sw_version': 'Debian GNU/Linux 12 (bookworm)\n', 'connections': []}, 'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>, 'force_update': False, 'encoding': 'utf-8', 'enabled_by_default': True, 'payload_available': 'online', 'payload_not_available': 'offline', 'qos': 0, 'availability_mode': 'latest'}, this is not expected. Please correct your configuration. The device name prefix will be stripped off the entity name and becomes 'Uptime'

check_cpu_load can't parse float

I don't know if it is because I use FR locales but check_cpu_load won't work as it should.
Uptime returns 0,91 instead of 0.91

To fix it, change line 27 from this :
cpu_load = p.split("average:")[1].split(",")[0].replace(' ', '')
to that to change "," in "." :
cpu_load = p.split("average:")[1].split(", ")[0].replace(' ', '').replace(',', '.')

Feature request: IP address sensor

Hi, thanks for a fantastic tool. I realise it's pretty much static data, but it would be great if the monitor were able to send the ipv4 and/or ipv6 address of the pi via MQTT.

Not all devices have a vendor in cpuinfo

Hello

Thanks for the good tool, I was able to run it on my TV box running Armbian.
But I had to make an edit because not all processors have vendor information in them; receiving the manufactory fails with an error.

Could you add a check for this situation or provide an alternative option for obtaining data, for example, use model name instead of vendor.

Below is the error trace:

Traceback (most recent call last):
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 711, in
gather_and_send_info()
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 617, in gather_and_send_info
print_measured_values(cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, uptime_seconds, wifi_signal, wifi_signal_dbm, rpi5_fan_speed)
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 205, in print_measured_values
""".format(config.version, check_model_name(), get_manufacturer(), get_os(), hostname, get_network_ip(), get_mac_address())
^^^^^^^^^^^^^^^^^^
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 143, in get_manufacturer
pretty_name = pretty_name.split(':')[1].replace('\n', '')
~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

How to monitor externally mounted array

Hello, I use rpi as NAS and have raid0 array. How should I modify the .py script to display (or add mqtt message for) external storage?

/dev/md0 on /RAID3T

Thanks, Jan

Feature request: option to switch a display

Would it be possible to have a switch similar to the power off but only turn off/on the display. I am currently using the shell command 'xset -display :0 dpms force off' or 'xset -display :0 dpms force on'.
The mqtt option would avoid the ssh authentication issue.
I am trying to automate the touchscreen connected to the pi.
Thank you

SWAP

Hi whats the swap?

vcgencmd: not found

Hello

Im running RPi4 with Ubuntu fpr RPI and this is the error Im getting. Any idea what is wrong?

ubuntu@ubuntu:~/rpimonitor$ /usr/bin/python3.8 rpi-cpu2mqtt.py
/bin/sh: 1: vcgencmd: not found
Traceback (most recent call last):
File "rpi-cpu2mqtt.py", line 198, in
cpu_temp = check_cpu_temp()
File "rpi-cpu2mqtt.py", line 54, in check_cpu_temp
cpu_temp = str(p).replace('\n', ' ').replace('\r', '').split("=")[1].split("'")[0]

free -t not available on Alpine Linux

I'm running Alpine on my Raspi 5, it's free command doesn't support the "total" option -t. When using the Memory or Swap reporting, the script fails with the following error

BusyBox v1.36.1 (2023-11-07 18:53:09 UTC) multi-call binary.

Usage: free [-bkmgh]

Display free and used memory
Traceback (most recent call last):
  File "/home/markus/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 712, in <module>
    gather_and_send_info()
  File "/home/markus/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 612, in gather_and_send_info
    cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, uptime_seconds, wifi_signal, wifi_signal_dbm, rpi5_fan_speed = collect_monitored_values()
                                                                                                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/markus/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 595, in collect_monitored_values
    memory = check_memory()
             ^^^^^^^^^^^^^^
  File "/home/markus/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 86, in check_memory
    memory = round(float(memory.decode("utf-8").replace(",", ".")))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: ''

Here's an example output of free as-is:

              total        used        free      shared  buff/cache   available
Mem:        8132632     5525592      156444      292000     2450596     2232356
Swap:             0           0           0

I can get it to work when removing the -t and filtering by Mem:

free | grep -i mem | awk 'NR == 1 {print $3/$2*100}'

For Swap, I also get the same issue as #11 (Division by Zero).

Is it possible to enter a clientID?

I'm searching my logs and so many clients have random names generated by not using clientID, it would be good to be able to fix it so I can parse logs better.

Change uptime to timestamp

Can I suggest changing uptime, to a last boot timestamp. That way Home Assistant will automatically set the time formatting.
Like this:
image
image

Mqtt auto discovery parameters :

{
  "name": "Last Boot",
  "state_topic": "xxxx",
  "device_class": "timestamp",
  "value_template": "{{ as_datetime(value) }}",
  "unique_id": "xxxx",
   etc,
   etc
  }
}

DeprecationWarning: Callback API version 1 is deprecated

I get the following error:

(foobar) pi@meteotux:~/rpi-mqtt-monitor $ python3 /home/pi/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py -d

:: rpi-mqtt-monitor
   Version: 0.8.9

:: Device Information
   Model Name: Raspberry Pi 4 Model B Rev 1.2
   Manufacturer: Raspberry Pi
   OS: Debian GNU/Linux 12 (bookworm)
   Hostname: meteotux
   IP Address: 192.168.1.182
   MAC Address: DC-A6-32-6B-18-84
   Update Check Interval: 3600 seconds

:: Measured values
   CPU Load: 12.0 %
   CPU Temp: 57 °C
   Used Space: 56 %
   Voltage: False V
   CPU Clock Speed: False MHz
   Swap: False %
   Memory: 16 %
   Uptime: 0 days
   Wifi Signal: False %
   Wifi Signal dBm: False
   RPI5 Fan Speed: False RPM
   Update Available: {"installed_ver": "0.8.9", "new_ver": "0.8.9"}
    
/home/pi/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py:398: DeprecationWarning: Callback API version 1 is deprecated, update to latest version
  client = paho.Client(client_id="rpi-mqtt-monitor-" + hostname + str(int(time.time())))
MQTT error:  failed to receive on socket: [Errno 104] Connection reset by peer


Any help to this?

And also this makes no sense:
Update Available: {"installed_ver": "0.8.9", "new_ver": "0.8.9"}

Raspian 12 Value Error

When i try to let the the rpi-cpu2mqqt.py run i get the following error:

Traceback (most recent call last):
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 730, in
gather_and_send_info()
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 630, in gather_and_send_info
cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, uptime_seconds, wifi_signal, wifi_signal_dbm, rpi5_fan_speed = collect_monitored_values()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 613, in collect_monitored_values
memory = check_memory()
^^^^^^^^^^^^^^
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 84, in check_memory
memory = round(float(memory.decode("utf-8").replace(",", ".")))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: ''

Illegal discovery topic

rpi-monitor uses full hostname for the device name but according to the linked documentation, object_id (device) can contain only [a-zA-Z0-9_-]

[homeassistant.components.mqtt.discovery] Received message on illegal discovery topic 'homeassistant/sensor/rpi-MQTT-monitor/some.hostname.com_uptime_days/config'. The topic contains not allowed characters. For more information see https://www.home-assistant.io/integrations/mqtt/#discovery-topic

ValueError: could not convert string to float: ''

When i try to let the the rpi-cpu2mqqt.py run i get the following error:

Traceback (most recent call last):
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 730, in
gather_and_send_info()
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 630, in gather_and_send_info
cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, uptime_seconds, wifi_signal, wifi_signal_dbm, rpi5_fan_speed = collect_monitored_values()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 613, in collect_monitored_values
memory = check_memory()
^^^^^^^^^^^^^^
File "/root/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py", line 84, in check_memory
memory = round(float(memory.decode("utf-8").replace(",", ".")))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: ''

Update time

Thanks for your job 😊

if I understand correctly rpi sends data every 5 minutes... is it possible to decrease the time?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.