set daemon 120 set alert alert@domain.com set mailserver localhost set httpd port 2812 and allow localhost allow admin:monit set logfile /var/log/monit.log #set mail-format { from: monit@server.com } # system check system localhost if loadavg (1min) > 4 then alert if loadavg (5min) > 2 then alert if cpu usage (user) > 70% then alert if cpu usage (system) > 30% then alert if cpu usage (wait) > 20% then alert if swap usage > 25% then alert if memory usage > 50% then alert if memory usage > 65% then exec "/usr/sbin/apachectl graceful" # filesystem check filesystem tmp with path "/tmp" if failed permission 1777 then exec "/bin/chmod 1777 /tmp" # 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 # cron check process crond with pidfile /var/run/crond.pid start program "/etc/init.d/crond start" stop program "/etc/init.d/crond 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 start" with timeout 60 seconds stop program = "/etc/init.d/mysql stop" if failed host localhost port 3306 protocol mysql then alert if cpu > 40% for 1 cycles then alert if cpu > 60% for 2 cycles then alert if cpu > 80% for 2 cycles then restart if 5 restarts within 5 cycles then timeout group server # 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 # courier-imap check process courier-imapd with pidfile /var/run/imapd.pid start program = "/etc/init.d/courier-imap start" stop program = "/etc/init.d/courier-imap stop" if failed port 143 then restart if 5 restarts within 5 cycles then timeout # apache check process apache2 with pidfile /var/run/httpd.pid start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop" if failed port 80 protocol http request "/server-status?auto" then restart #if failed port 80 protocol http request "/whm-server-status?auto" then restart if 5 restarts within 5 cycles then timeout