¿Qué es Monit?
De acuerdo con su propia definición, Monit es una utilidad gratuita y Open Source para administrar y monitorear procesos, archivos, directorios y filesystems en un sistema Unix. Realiza tareas automáticas de mantenimiento y reparación y puede ejecutar acciones significativas durante situaciones de error.
método de instalación
apt-get install monit
para iniciarlo automáticamente
vamos a /etc/default/monit
y cambiamos startup=0 por 1
configuración global
/etc/monit/monitrc
Aquí pondré lo más relevante
Que chequee cada 2 minutos
set daemon 120 # check services at 2-minute intervals
Activo el log
set logfile syslog facility log_daemon
Activo el servidor web en el puerto 2812
set httpd port 2812 and
El servidor va a mostrarse por la ip
use address 10.0.0.9
Permito aceso a esta ip solamente
allow 10.0.0.18
Usuario y password con acceso a la interfaz web
allow admin:clav3
Aquí pondré los servicios que estoy monitoreando estos van dentro de este directorio.
/etc/monit/monitrc/conf.d/
Creo los ficheros touch /etc/monit/monitrc/conf.d/amavisd
y dentro le pongo esto:
check process amavis with pidfile /var/run/amavis/amavisd.pid
group amavis
start program = "/etc/init.d/amavis start"
stop program = "/etc/init.d/amavis stop"
if failed port 10024 then restart
if 5 restarts within 5 cycles then timeout
touch /etc/monit/monitrc/conf.d/postfix
y dentro le pongo esto:
check process postfix with pidfile /var/spool/postfix/pid/master.pid
group postfix
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
depends on postfix_rc
check file postfix_rc with path /etc/init.d/postfix
group postfix
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
touch /etc/monit/monitrc/conf.d/dovecot
y dentro le pongo esto:
check process dovecot with pidfile /var/run/dovecot/master.pid
start program = "/etc/init.d/dovecot start"
stop program = "/etc/init.d/dovecot stop"
group dovecot
if failed host localhost port 993 type tcpssl sslauto protocol imap then restart
if failed host localhost port 143 protocol imap then restart
if 5 restarts within 5 cycles then timeout
depends dovecot_init
depends dovecot_bin
check file dovecot_init with path /etc/init.d/dovecot
group dovecot
check file dovecot_bin with path /usr/sbin/dovecot
group dovecot
touch /etc/monit/monitrc/conf.d/clamav-daemon
y dentro le pongo esto:
check process clamav-daemon with pidfile /var/run/clamav/clamd.pid
group clamav
start program = "/etc/init.d/clamav-daemon start"
stop program = "/etc/init.d/clamav-daemon stop"
if 5 restarts within 5 cycles then timeout
depends on clamavd_bin
depends on clamavd_rc
check file clamavd_bin with path /usr/sbin/clamd
group clamav
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 clamavd_rc with path /etc/init.d/clamav-daemon
group clamav
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
touch /etc/monit/monitrc/conf.d/apache2
y dentro le pongo esto:
check process apache2 with pidfile /var/run/apache2.pid
group www-data
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if failed port 80 then restart
if 5 restarts within 5 cycles then timeout
depends on apache_bin
depends on apache_rc
check file apache_bin with path /usr/sbin/apache2
group www-data
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 apache_rc with path /etc/init.d/apache2
group www-data
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
Como ven el monit arranca
root@mail:~# date
mié oct 24 14:26:17 CDT 2012
root@mail:~# invoke-rc.d postfix stop
Stopping Postfix Mail Transport Agent: postfix.
root@mail:~# date
mié oct 24 14:27:58 CDT 2012
root@mail:~# date
mié oct 24 14:28:01 CDT 2012
root@mail:~# invoke-rc.d postfix status
postfix is running.
root@mail:~#
No hay comentarios:
Publicar un comentario