piframe/docs/monit.md

1.2 KiB

System Monitoring

The below commands will setup monit to track key elements of the PiFrame hardware and software. monit is a very light weight monitoring solution and is used to ensure key parts of the system are in a reasonable state and working.


apt install monit
nano -w /etc/monit/monitrc
    set httpd port 2812 and
        use address 0.0.0.0
        allow admin:monit
    set mailserver domain.tld port 587
               username "piframe@domain.tld" password "apassword"
               using tls
cat > /etc/monit/conf.d/rootfs <<EOF
check filesystem rootfs with path /
    if space usage > 80% then alert
EOF
cat > /etc/monit/conf.d/tankfs <<EOF
check filesystem tankfs with path /tank
    if space usage > 80% then alert
EOF
cat > /etc/monit/conf.d/pf-ui <<EOF
check process pf-ui matching /usr/local/bin/pf-ui
    start program = "/usr/bin/systemctl start pf-ui"
    stop program = "/usr/bin/systemctl stop pf-ui"
    if does not exist then alert
    if does not exist for 2 cycles then restart
EOF
systemctl enable --now monit
systemctl restart monit
firewall-cmd --zone=public --permanent --add-port=2812/tcp
firewall-cmd --reload