set init set daemon 300 # Poll at 5-minute intervals set logfile syslog facility log_daemon set alert me@myaddress.tld set httpd port 2812 and use address localhost allow localhost # Allow localhost to connect allow xxxx:xxxxx # Allow Basic Auth # Check Bind (chrooted) check process DNS with pidfile /var/named/chroot/var/run/named/named.pid start program = "/etc/init.d/named start" stop program = "/etc/init.d/named stop" if failed host 127.0.0.1 port 53 type tcp protocol dns then alert if failed host 127.0.0.1 port 53 type udp protocol dns then alert if 5 restarts within 5 cycles then timeout # Make sure SSH is running check process SSH 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 # Make sure MySQL is running check process MySQL with pidfile /var/run/mysqld/mysqld.pid group database start program = "/etc/init.d/mysqld start" stop program = "/etc/init.d/mysqld stop" if failed port 3306 protocol mysql then restart if 5 restarts within 5 cycles then timeout #Make sure Apache is running and serving content check process HTTP with pidfile /var/run/httpd.pid group www start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop" if failed host 192.168.xxx.xxx port 80 protocol HTTP and request "/monit" then restart if cpu usage is greater than 60 percent for 2 cycles then alert if cpu usage > 98% for 5 cycles then restart if 5 restarts within 5 cycles then timeout # Check virtual-host www.site1.tld for content check host SITE1 with address www.site1.tld if failed url http://www.site1.tld and content == "Search string" with timeout 15 seconds then alert alert me@myaddress.tld with mail-format {subject: SITE1 is down! } # Check virtual-host www.site2.tld for content check host SITE2 with address www.site2.tld if failed url http://www.site2.tld and content == "Search string" with timeout 15 seconds then alert alert me@myaddress.tld with mail-format {subject: SITE2 is down! }