====== Monit Examples ====== * [[Monit]] ==== Reminders ==== Keep sending reminders that a service is broken. Since the default for our setup is every 2 minutes, once every day would be 720 cycles. Once a day: ... alert with reminder on 720 cycles Every half hour: ... alert with reminder on 15 cycles Every hour: ... alert with reminder on 30 cycles Twice a day: ... alert with reminder on 240 cycles ==== Apache ==== check process apache with pidfile /var/run/apache2.pid start program = "/etc/init.d/apache2 restart" with timeout 60 seconds stop program = "/etc/init.d/apache2 stop" if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if 5 restarts within 5 cycles then timeout ==== dhcpcd ==== check process dhcpcd with pidfile /var/run/dhcpcd.pid ==== dnsmasq ==== check process dnsmasq with pidfile /var/run/dnsmasq.pid start program = "/etc/init.d/dnsmasq restart" with timeout 60 seconds stop program = "/etc/init.d/dnsmasq stop" if 5 restarts within 5 cycles then timeout ==== fcron ==== check process fcron with pidfile /var/run/fcron.pid start program = "/etc/init.d/fcron restart" with timeout 60 seconds stop program = "/etc/init.d/fcron stop" if 5 restarts within 5 cycles then timeout ==== mysqld ==== check process mysqld with pidfile /var/run/mysqld/mysqld.pid start program = "/etc/init.d/mysql restart" with timeout 60 seconds stop program = "/etc/init.d/mysql stop" if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if 5 restarts within 5 cycles then timeout ==== netatalk ==== check process netatalk with pidfile /var/run/afpd.pid start program = "/etc/init.d/atalk restart" with timeout 60 seconds stop program = "/etc/init.d/atalk stop" if 5 restarts within 5 cycles then timeout ==== postfix ==== check process postfix with pidfile /var/spool/postfix/pid/master.pid start program = "/etc/init.d/postfix start" stop program = "/etc/init.d/postfix stop" if failed port 25 protocol smtp then restart if 5 restarts within 5 cycles then timeout ==== sshd ==== check process sshd with pidfile /var/run/sshd.pid start program "/etc/init.d/sshd start" stop program "/etc/init.d/sshd stop" if failed port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout ==== stunnel ==== check process stunnel with pidfile /var/run/stunnel/stunnel.pid start program = "/etc/init.d/stunnel restart" with timeout 60 seconds stop program = "/etc/init.d/stunnel stop" if 5 restarts within 5 cycles then timeout ==== syslog-ng ==== check process syslog-ng with pidfile /var/run/syslog-ng.pid start program = "/etc/init.d/syslog-ng restart" with timeout 60 seconds stop program = "/etc/init.d/syslog-ng stop" if 5 restarts within 5 cycles then timeout ==== tmp ==== Checks the permissions on ''/tmp'' to make sure they are correct. check directory tmp with path /tmp if failed perm 1777 then exec "/bin/chmod 1777 /tmp"