mqtt-system-monitor

mqtt-system-monitor is a small program that periodically sends reports with MQTT to Home Assistant.
flowchart TD
MQTT --> HA[Home Assistant]
Host1 -->|mqtt-system-monitor| MQTT
Host2 -->|mqtt-system-monitor| MQTT
Configuration
The configuration file is /etc/mqtt-system-monitor.conf. The available configuration settings are:
log-verbosity: Log verbosity. Default =2(warning)- 1 => Error
- 2 => Warning
- 3 => Info
- 4 => Debug
- 5 => Trace
mqtt.hostname: hostname of the MQTT broker.localhostby defaultmqtt.port: port of the MQTT broker.1883by defaultmqtt.user: user for the MQTT broker connection. empty by defaultmqtt.password: password for the MQTT broker connection. empty by defaultmqtt.entity: Name of the device. Defaults to the hostname of the machine.mqtt.update-period: Frequency for polling and updates in seconds.10by defaultmqtt.registration-prefix: Prefix for the registration topic.homeassistantby default. This must match the discovery prefix set in the MQTT configuration.sensors.temperature: Temperature sensor to monitor. Example :coretemp Package id 0sensors.network: Network interface to monitor. Example :wlan0
Usage
A systemd unit is provided. If used:
The program can be run as a standalone program:
Sensors
available
Returns ON (connected) as long as mqtt-system-monitor is running and OFF (disconnected) otherwise
cpu_temp
Reports CPU Temperature in °C, if sensors.temperature is set
cpu_usage
Reports the current total CPU usage in %.
memory_usage
Reports the current memory usage in %.
net_tx
Reports the rate of outgoing data in KiB/s during the last mqtt.update-period seconds, if sensors.network is set.
net_rx
Reports the rate of incoming data in KiB/s during the last mqtt.update-period seconds, if sensors.network is set.
Credits
Some code is based on https://github.com/cmargiotta/mqtt-system-monitor which has the same purpose, but I couldn't do what I wanted with just Lua scripts.