Darüber hinaus verschickt es eine E-Mail wenn ein Dienst neu gestartet werden musste. Über eine Weboberfläche kann man alle zur Überwachung eingestellten Dienste stoppen, neu starten sowie die Systembelastung die der Dienst verursacht sehen. Die Konfiguration ist darüber leider nicht möglich sondern muss per Hand in der Konfigurationsdatei vorgenommen werden.
Monit unter Debian installieren - Linux Dienste überwachen
~# apt-get install monit
~# vim /etc/monit/monitrc
# Aktualisierungsinterval in Sekunden
set daemon 120
# Speicherort des Logfiles
set logfile /var/log/monit
# Mailversand ueber
set mailserver localhost # primary mailserver
set mail-format { from: monit@DOMAIN DES SERVERS}
# Mail an
set alert DEINE-EMAIL@DOMAIN
#Erreichbarkeit der Weboberflaesche
set httpd port 2812 and
use address MONIT.BEISPIELDOMAIN.TLD
allow BENUTZERNAME:PASSWORT
# Ueberwachung http
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 cpu is greater than 60% for 2 cycles then alert
if cpu > 85% for 5 cycles then restart
if totalmem > 600 MB for 5 cycles then restart
if children > 300 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
# Ueberwachung mysql
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
# Ueberwachung 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
# Ueberwachung 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
# Ueberwachung ssh
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
#samba
check process smbd with pidfile /var/run/samba/smbd.pid
group samba
start program = “/etc/init.d/samba restart”
stop program = “/etc/init.d/samba stop”
if failed host localhost port 139 type TCP then restart
if 5 restarts within 5 cycles then timeout
depends on smbd_bin
check file smbd_bin with path /usr/sbin/smbd
if failed uid root then unmonitor
if failed gid root then unmonitor
group samba
check file nmbd_bin with path /usr/sbin/nmbd
group samba
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
check process nmbd with pidfile /var/run/samba/nmbd.pid
group samba
start program = “/etc/init.d/samba restart”
stop program = “/etc/init.d/samba stop”
if failed host localhost port 138 type UDP then restart
if failed host localhost port 137 type UDP then restart
if 5 restarts within 5 cycles then timeout
depends on nmbd_bin
Sollte statt Postfix ein anderer MTA installiert sein so muss die Konfiguration selbstverständlich anders aussehen.
~# monit –t
~# vim /etc/default/monit
Hier muss die Zeile startup=0 auf startup=1 geändert werden.
~# /etc/init.d/monit restart
Ab jetzt werden die Dienste überwacht und ggf. neu gestartet.





