Afin de sortir en toute tranquillité (enfin façon de parler…), un point à ne pas négliger consiste à monitorer automatiquement votre serveur web. Et dans le domaine il n’y a pas 36 solutions : vous devez utiliser un logiciel spécialisé qui fasse le sale boulot (reboot serveur web en cas de plantage, etc.) à votre place 24/24h, 7/7j, et ce tout au long de l’année
Là encore plusieurs solutions sont possibles, et comme j’utilise Monit je vous présente… Monit!
Il n’y pas grand chose à préciser si-ce n’est de suivre les indications de paramétrage ci-dessous:
1- Téléchargez et installez Monit:
aptitude install monit
2- Configurez le service (edition de /etc/monit/monitrc):
set daemon 60 set logfile syslog facility log_daemon set mailserver localhost set mail-format { from: Monit@vds.com } set alert email@email set httpd port 2812 and allow root:pass check process sshd with pidfile /var/run/sshd.pid start program "/etc/init.d/ssh start" stop program "/etc/init.d/ssh stop" if failed port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout check process mysql 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 check process apache with pidfile /var/run/apache2.pid group www start program = "/etc/init.d/apache2 start" stop program = "/etc/init.d/apache2 stop" if failed host le.serveur.org port 80 protocol http and request "/monit/token" then restart if cpu is greater than 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if totalmem > 500 MB for 5 cycles then restart if children > 250 then restart if loadavg(5min) greater than 10 for 8 cycles then stop if 3 restarts within 5 cycles then timeout 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
Pensez à éditer certaines lignes, par ex: allow root:pass (login admin), if failed port 22 (No du port SSH), le.serveur.org (adresse du serveur)…
3- Création du fichier de surveillance d’Apache:
mkdir /var/www/monit
echo "Hello" > /var/www/monit/token4- Activer le daemon (en éditant /etc/default/monit) :
startup=1 CHECK_INTERVALS=180
5- Lancer Monit
/etc/init.d/monit start
Et hop, la surveillance est active! Pour acceder au panneau de contrôle : http://le.nom.du.serveur:2812/