Open giovi321 opened 3 years ago
I figured out with a bash script if anybody is interested:
Prerequisites:
apt-get install mosquitto-clients
For the disks:
#!/bin/sh
df -hl | grep '/dev/md127' | awk '{;percent+=$5;} END{print percent}' | column -t > /home/programmi/mqtt/root.txt
df -hl | grep '/dev/mapper/4tb' | awk '{;percent+=$5;} END{print percent}' | column -t > /home/programmi/mqtt/4tb.txt
df -hl | grep '/dev/mapper/3tb' | awk '{;percent+=$5;} END{print percent}' | column -t > /home/programmi/mqtt/3tb.txt
df -hl | grep '/dev/mapper/backup' | awk '{;percent+=$5;} END{print percent}' | column -t > /home/programmi/mqtt/backup.txt
df -hl | grep '/dev/mapper/vm' | awk '{;percent+=$5;} END{print percent}' | column -t > /home/programmi/mqtt/vm.txt
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P mqtt_password -t GC01SRVR/disk_usage/root -f /home/programmi/mqtt/root.txt
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P mqtt_password -t GC01SRVR/disk_usage/4tb -f /home/programmi/mqtt/4tb.txt
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P password -t GC01SRVR/disk_usage/3tb -f /home/programmi/mqtt/3tb.txt
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P password -t GC01SRVR/disk_usage/backup -f /home/programmi/mqtt/backup.txt
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P password -t GC01SRVR/disk_usage/vm -f /home/programmi/mqtt/vm.txt
For the CPU:
#!/bin/bash
awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) ; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat) > /home/prog>
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P password -t GC01SRVR/cpu_usage -f /home/programmi/mqtt/cpu.txt
For the memory available:
#!/bin/bash
AVAILABLEMEM=$(grep MemAvailable /proc/meminfo | grep -o -E '[0-9]+')
echo "scale=2;$AVAILABLEMEM/1000000" | bc > /home/programmi/mqtt/memoryavailable.txt
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P password -t GC01SRVR/memory_available -f /home/programmi/mqtt/memoryavailable.txt
For the uptime
#!/bin/bash
UPTIME=$(cat /proc/uptime | head -n1 | awk '{print $1;}')
echo "scale=2;$UPTIME/60/60/24" | bc > /home/programmi/mqtt/uptime.txt
mosquitto_pub -h 192.168.1.65 -p 1883 -u user -P password -t GC01SRVR/uptime -f /home/programmi/mqtt/uptime.txt
Hi, it seems that my raid 0 devices are not liked by the python program. Here's my psmqtt.conf:
Forgot to add the error I get:
Could you help me out a bit please? :)