This is an old revision of the document!
Monitoraggio processi con Monit
In generale un processo (demone) una volta lanciato deve funzionare, punto e basta. Può capitare però che per colpa di qualche bug non ancora risolto, il processo muoia e sia neccessario riavviarlo manualmente.
E' il caso di Spamassassin 3.3.2 con Perl 5.14.2 su Debian Wheezy, ogni tanto il processo spamd
muore senza motivo. Nei file di log si trova:
spamd[4563]: prefork: adjust: 10 idle children more than 9 maximum idle children. Decreasing spamd children: 27150 killed. spamd[4563]: spamd: handled cleanup of child pid [27150] due to SIGCHLD: interrupted, signal 2 (0002) spamd[4563]: spamd: handled cleanup of child pid [27151] due to SIGCHLD: interrupted, signal 2 (0002)
e poi niente altro (il processo spamd
padre è morto). Potrebbe trattarsi di un bug, secondo i seguenti post:
Come workaround al problema si installa monit, che semplicemente monitora la presenza del demone spamd
e se necessario lo riavvia.
Configurazione di monit
Questo lo snippet di configurazione da salvare in /etc/monit/conf.d/spamd
:
check process spamd with pidfile /var/run/spamd.pid group spamd start program = "/etc/init.d/spamassassin start" stop program = "/etc/init.d/spamassassin stop" if 5 restarts within 5 cycles then timeout if cpu usage > 99% for 5 cycles then alert if mem usage > 99% for 5 cycles then alert depends on spamd_bin depends on spamd_rc check file spamd_bin with path /usr/sbin/spamd group spamd if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor check file spamd_rc with path /etc/init.d/spamassassin group spamd if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor
Poi alcuni parametri sono stati aggiustati in /etc/monit/monitrc
:
set daemon 120 # check services at 2-minute intervals with start delay 240 # optional: delay the first check by 4-minutes (by set mailserver localhost set alert support@texnet.it # receive all alerts set httpd port 2812 and use address 62.48.51.60 # only accept connection from localhost allow 62.48.51.60 # allow localhost to connect to the server and allow 62.48.51.8 # allow a remote host to connect to the server and allow admin:MySecret # require user 'admin' with password 'monit' allow @monit # allow users of group 'monit' to connect (rw) allow @users readonly # allow users of group 'users' to connect readonly