# /etc/monit/conf.d/config # Configuration de Monit de base set daemon 120 # verif toutes les 2 minutes with start delay 240 # 1ere verif après 4min set logfile syslog facility log_daemon # précise les fichiers de logs set mailserver localhost # précise le serveur de mail pour les alertes set eventqueue # si le serveur de mail down, on stock les alertes basedir /var/monit # répertoire de stockage slots 100 # nomber d'alertes max set mail-format { # le format du mail from: monit@$HOST subject: monit alert -- $EVENT $SERVICE } set alert votreEmail@truc.fr # qui reçoit toutes les alertes # set alert deuxieme-adresse@truc.fr only on { timeout } # pour être précis set httpd port 4598 and allow adminMonit:pass # Services # Apache2 check process apache with pidfile /var/run/apache2.pid group apache start program = "/etc/init.d/apache2 start" with timeout 60 seconds stop program = "/etc/init.d/apache2 stop" if cpu > 70% for 2 cycles then alert if cpu > 90% for 5 cycles then restart if children > 250 then restart if failed host 127.0.0.1 port 80 protocol http then restart if 5 restarts within 5 cycles then timeout # MySQL check process mysqld with pidfile /var/run/mysqld/mysqld.pid group database start program = "/etc/init.d/mysql start" stop program = "/etc/init.d/mysql stop" if failed host 127.0.0.1 port 3306 then restart if 5 restarts within 5 cycles then timeout # SSH check process sshd with pidfile /var/run/sshd.pid group ssh start program = "/etc/init.d/ssh start" stop program = "/etc/init.d/ssh stop" if failed host 127.0.0.1 port 2242 protocol ssh then restart if 5 restarts within 5 cycles then timeout # Postfix check process postfix with pidfile /var/spool/postfix/pid/master.pid group mail 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 # FTP check process proftpd with pidfile /var/run/proftpd.pid start program = "/etc/init.d/proftpd start" stop program = "/etc/init.d/proftpd stop" if failed port 21 protocol ftp then restart if 5 restarts within 5 cycles then timeout # BIND check process bind9 with pidfile /var/run/named/named.pid group bind start program = "/etc/init.d/bind9 start" stop program = "/etc/init.d/bind9 stop" if failed port 53 then restart if 5 restarts within 5 cycles then timeout # POP3 check process pop3 with pidfile /var/run/courier/pop3d.pid group mail start program = "/etc/init.d/courier-pop start" stop program = "/etc/init.d/courier-pop stop" if failed port 110 then restart if 5 restarts within 5 cycles then timeout # IMAP check process imap with pidfile /var/run/courier/imapd.pid group mail 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 # Disk # SDA1 check device sda1 with path /dev/sda1 group system if space usage > 85% then alert if space usage > 90% then exec "/root/script/cleanup.sh" # SDA2 check device sda2 with path /dev/sda2 group system if space usage > 85% then alert