martes, 31 de marzo de 2009

Nagios 3 en Debian Squeeze

Instalacion y configuracion general y basica de Nagios 3 en un sistema Debian Squeeze/sid.


1) # apt-get update

2) # apt-get install nagios3 nagios-nrpe-plugin

3) # cd /etc/nagios3; htpasswd -c htpasswd.users nagiosadmin

4) # cp /etc/nagios3/apache2.conf /etc/apache2/sites-enabled

5) # /etc/init.d/apache2 restart

6) http://localhost/nagios3/

7) Definiendo mis propios comandos, utilizando los plugins de Nagios.

# vi /etc/nagios3/commands.cfg


define command{
command_name check-ldap
command_line $USER1$/check_ldap -H $HOSTADDRESS$ -3 -b "dc=dominio,dc=dominio1"
}

define command{
command_name check_alfred
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 9000
}

define command{
command_name check_root_partition_remote
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_disk
}




8) Cambiando detalles de configuracion:

# vi /etc/nagios3/nagios.cfg


cfg_file=/etc/nagios3/contactgroups.cfg
cfg_file=/etc/nagios3/contacts.cfg
cfg_file=/etc/nagios3/timeperiods.cfg
cfg_file=/etc/nagios3/hostgroups.cfg
cfg_file=/etc/nagios3/hosts.cfg
cfg_file=/etc/nagios3/services.cfg


9) Creando cada archivo que defini en el apartado anterior:

# vi /etc/nagios3/contactgroups.cfg
define contactgroup{
contactgroup_name SysAdmin
alias Admin
members Sistemas
}



# vi /etc/nagios3/contacts.cfg

define contact{
contact_name Sistemas
alias SysAdmin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email mi_dir@corre
}




# vi /etc/nagios3/timeperiods.cfg

define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}


# 'workhours' timeperiod definition
define timeperiod{
timeperiod_name workhours
alias "Normal" Working Hours
monday 10:30-19:00
tuesday 10:30-19:00
wednesday 10:30-19:00
thursday 10:30-19:00
friday 10:30-19:00
}


# 'nonworkhours' timeperiod definition
define timeperiod{
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00
}



# vi /etc/nagios3/hosts.cfg

# 'msantos-pruebas.ing.ollin' host definition
define host{
use generic-host ; Name of host template to use
host_name m-pruebas.ing
alias m-pruebas.ing
address 172.16.30.2
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,u,r
contact_groups SysAdmin
}

# 'piedra.domain' definition
define host{
use generic-host ; Name of host template to use
host_name piedra.domain
alias piedra.domain
address 172.16.30.115
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period workhours
notification_options d,u,r
contact_groups SysAdmin
}



# vi /etc/nagios3/services.cfg

define service{
use generic-service ; Name of service template to use
host_name backups.domain, piedra.domain, m-prueba.ing
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups SysAdmin
notification_interval 120
notification_period 24x7
notification_options c,r
check_command check_ping!100.0,20%!500.0,60%
}

# Service definition
define service{
use generic-service ; Name of service template to use
host_name backups.domain
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups SysAdmin
notification_interval 120
notification_period 24x7
notification_options c,r
check_command check_http
}

No hay comentarios: