Er is dringend nood aan monitoring van alle interne apparaten. Het is dan ook zeer belangrijk dat ik onmiddellijk een email kan krijgen wanneer de RPI niet beschikbaar meer zou zijn. Het belangrijkste is dat de RPI een zo klein mogelijke downtime kent omdat deze instaat voor periodieke metingen. Hoe minder downtime hoe meer meetwaarden dus.
Mijn ogen vielen op de opensource tool Monit. Deze tool is compatibel met ARM processoren zoals de RPI en kan via apt-get eenvoudig geïnstalleerd worden.
Installatie agent
apt-get install monit
Controle onboot
Controleer dat START=yes voorkomt in
vim /etc/default/monit
Installatie Monitoring Server (M/Monit)
cd /opt wget https://mmonit.com/dist/mmonit-3.5.1-linux-arm.tar.gz tar -xvf mmonit-3.5.1-linux-arm.tar.gz
Autostart M/Monit via Monit Agent
vim /etc/monit/monitrc check process mmonit with pidfile /opt/mmonit-3.5.1/logs/mmonit.pid start program = "/opt/mmonit-3.5.1/bin/mmonit" stop program = "/opt/mmonit-3.5.1/bin/mmonit stop"
Autostart M/Monit via systemctl
cd /lib/systemd/system
vim mmonit.service
[Unit]
Description = Easy, proactive monitoring of Unix systems, network and cloud services
After = network.target
[Service]
Type=forking
ExecStart = /opt/mmonit-3.5.1/bin/mmonit start
ExecStop = /opt/mmonit-3.5.1/bin/mmonit stop
PIDFile = /opt/mmonit-3.5.1/logs/mmonit.pid
[Install]
WantedBy = multi-user.target
systemctl enable mmonit
systemctl start mmonit
systemctl status mmonit
Monit Agent koppelen
vim /etc/monit/monitrc
set mmonit http://monit:password@192.168.10.15:8080/collector set httpd port 2812 allow localhost allow 192.168.10.15 allow monit:password
Extra service toevoegen
check device root with path /dev/root if SPACE usage > 80% then alert check process sshd with pidfile /var/run/sshd.pid start program "/etc/init.d/ssh start" stop program "/etc/init.d/ssh stop" if failed port 22 protocol ssh then restart check process knxd matching "knxd"; start program = "/etc/init.d/knxd start" stop program = "/etc/init.d/knxd stop" # not working: if failed unixsocket /run/knx then alert check host fietology.zilverlinde.local with address 192.168.10.5 if failed ping then alert if failed port 3306 protocol mysql with timeout 15 seconds then alert if failed port 80 protocol http and request /domotics/assets/monitcheck with content = "MMonit OK" then alert check host cam-voordeur.zilverlinde.local with address 192.168.10.81 if failed ping then alert check host cam-garage.zilverlinde.local with address 192.168.10.80 if failed ping then alert check host onkyo.zilverlinde.local with address 192.168.10.41 if failed ping then alert
root@raspberrypi:/etc/monit # monit reload
Reinitializing monit daemon