freebsd:monit
Ceci est une ancienne révision du document !
Table des matières
monit
Installation
On lance un :
portugrade -N sysutils/monit
Configuration
Un fichier d'exemple est fourni dans /usr/local/etc/monitrc.sample, cependant les exemples fournis sont plutôt adaptés à linux.
On commence donc par copier le fichier d'exemple :
cp /usr/local/etc/monitrc.sample /usr/local/etc/monitrc
On pour le fonctionnement de base de monit on édite les lignes suivantes :
set daemon 60 # check services at 2-minute intervals set logfile syslog facility log_daemon set statefile /var/.monit.state set mailserver localhost # primary mailserver set httpd port 2812 allow md5 /chemin/vers/un/fichier/.htpasswd
Exemples de choses à monitorer
Pour le systèmes :
check system nom_de_la_machine if loadavg (1min) > 15 then alert if loadavg (5min) > 20 then alert if memory usage > 75% then alert if swap usage > 70% then alert if cpu usage (user) > 90% then alert if cpu usage (system) > 50% then alert if cpu usage (wait) > 20% then alert
Pour apache :
check process httpd with pidfile /var/run/httpd.pid start program = "/usr/local/etc/rc.d/apache22 start" with timeout 60 seconds stop program = "/usr/local/etc/rc.d/apache22 stop" if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if totalmem > 200.0 MB for 5 cycles then restart if children > 250 then restart if loadavg(5min) greater than 10 for 8 cycles then stop if failed host nom_du_site_a_monitorer port 80 protocol http and request "/index.php" then restart if 3 restarts within 5 cycles then timeout group www
Pour Mysql :
check process mysqld with pidfile /var/db/mysql/ambre.sheltem.com.pid group mysql start program = "/usr/local/etc/rc.d/mysql-server start" stop program = "/usr/local/etc/rc.d/mysql-server stop" if failed host 127.0.0.1 port 3306 then restart if 5 restarts within 5 cycles then timeout
Pour SSH :
check process sshd with pidfile /var/run/sshd.pid start program "/etc/rc.d/sshd start" stop program "/etc/rc.d/sshd stop" if failed port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout
Pour un serveur Murmur :
check process murmur with pidfile /var/run/murmur/murmur.pid start program "/usr/local/etc/rc.d/murmur start" stop program "/usr/local/etc/rc.d/murmur stop" if 5 restarts within 5 cycles then timeout
Traces
Dans le fichier de configuration on indique à monit d'envoyer les logs a syslog via le “canal” “daemon”, cependant, dans freebsd, il n'est pas défini on ajoute donc cette ligne dans /etc/syslog.conf :
daemon.info /var/log/daemon.log
freebsd/monit.1315302482.txt.gz · Dernière modification : 2011/09/06 09:48 de sheltem