Monit¶
System-Monitoring und Alerting.
Installation¶
sudo apt install monit
Grundkonfiguration¶
sudo nano /etc/monit/monitrc
set daemon 60
set logfile syslog facility log_daemon
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
# Mail-Konfiguration
set mailserver localhost port 25
set mail-format {
from: monit@example.com
subject: monit alert -- $EVENT $SERVICE
message:
Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
}
set alert admin@example.com
# Web-Interface
set httpd port 2812 and
allow admin:password
System-Überwachung¶
CPU und Memory¶
sudo nano /etc/monit/conf.d/system
check system $HOST
if loadavg (1min) > 10 then alert
if loadavg (5min) > 6 then alert
if memory usage > 75% then alert
if cpu usage (user) > 70% for 5 cycles then alert
Disk-Speicher¶
check filesystem rootfs with path /
if space usage > 80% then alert
if inode usage > 85% then alert
check filesystem var with path /var
if space usage > 85% then alert
Service-Überwachung¶
Webserver¶
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed host localhost port 80 protocol http then restart
if 5 restarts within 5 cycles then timeout
check process apache2 with pidfile /var/run/apache2/apache2.pid
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if failed host localhost port 80 protocol http then restart
if 5 restarts within 5 cycles then timeout
Mailserver¶
check process postfix with pidfile /var/spool/postfix/pid/master.pid
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
check process dovecot with pidfile /var/run/dovecot/master.pid
start program = "/etc/init.d/dovecot start"
stop program = "/etc/init.d/dovecot stop"
if failed port 143 protocol imap then restart
if 5 restarts within 5 cycles then timeout
Datenbank¶
check process mysql with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed port 3306 protocol mysql then restart
if 5 restarts within 5 cycles then timeout
Netzwerk-Überwachung¶
check network public with interface eth0
if failed link then alert
if changed link then alert
if saturation > 90% then alert
if download > 10 MB/s then alert
if upload > 10 MB/s then alert
Konfiguration testen¶
sudo monit -t
Service starten¶
sudo systemctl restart monit
sudo systemctl enable monit
Status prüfen¶
sudo monit status
sudo monit summary
Web-Interface¶
- URL:
http://localhost:2812 - Login: admin/password (wie konfiguriert)
Zurück zur Monitoring-Übersicht