Surveiller les services et alertes par email (monit)
Redémarrer automatiquement les services tombés et recevoir des alertes par email.
A quoi sert ce tutoriel
Le tutoriel "Surveiller les services et alertes par email (monit)" vous aide a atteindre cet objectif:
Redémarrer automatiquement les services tombés et recevoir des alertes par email.
Debian / Ubuntu
-
Installer monit : apt install -y monit - --- Configuration principale : /etc/monit/monitrc ---
- Décommenter et configurer l'interface web :
- set httpd port 2812 and use address localhost
- allow admin:motdepasse
- Configurer les alertes email :
- set mailserver smtp.gmail.com port 587
- username "[email protected]" password "motdepasse_app"
- using tlsv12
- set alert [email protected]
- --- Surveiller Apache ---
- Créer /etc/monit/conf.d/apache :
- check process apache2 with pidfile /var/run/apache2/apache2.pid
-
start program = "/bin/systemctl start apache2" -
stop program = "/bin/systemctl stop apache2" - if cpu > 80% for 2 cycles then alert
- if memory > 512 MB then alert
- --- Surveiller l'espace disque ---
- check filesystem rootfs with path /
- if space usage > 85% then alert
- --- Démarrer monit ---
-
systemctl enable --now monit -
monit reload && monit status