Nagios 3.0 – Instalación y Configuración

Nagios es un sistema de monitorización de equipos y de servicios de red, el cual permite, entre otras cosas, alertar los comportamientos no deseados.
En este ejemplo, efectuaremos la instalación de Nagios3 en una equipo con arquitectura i386, bajo el sistema operativo debian 6.0 (Squeeze).

Instalación:

operador@servidor:/~$ sudo aptitude install apache2 build-essential libgd2-noxpm-dev nagios3

Usuario y Contraseña por defecto:
usuario: nagiosadmin
contraseña: nagios

Configuración
Cambiar contraseña:
1.- Entrar al directorio nagios:

operador@servidor:/~$ cd /etc/nagios3

2.- Ejecutar el administrar de contraseñas:

operador@servidor:/~$ sudo htpasswd -c htpasswd.users nagiosadmin

3.- Colocar la nueva contraseña

New-password:
Re-type new password:

Nota:
La siguiente es un ejemplo de configuración básico de Nagios, el cual corresponde al monitorio de tres (03) equipos con GNU/Linux. El local (nagios), un remoto (debian) pertenecientes al grupo server-web y el último remoto (mariadb) perteneciente al grupo server-datos. En el caso del grupo server-web, serán monitoreados los servicios ssh y web, para el grupo server-datos, sera monitoreado el servicio mysql

Configuración:
1.- Archivo de configuración de Nagios:

Ruta: /etc/nagios3/
- nagios.cfg


2.- Archivo de configuración de nodos Nagios:

Ruta: /etc/nagios3/conf.d/
- nodos-nagios.cfg -> Dispositivos a chequear
- grupos-nagios.cfg -> Grupos de dispositivos a chequear
- servicios-nagios.cfg -> Servicios a ser chequeados
- templates.cfg -> Políticas aplicadas
- timeperiods_nagios.cfg -> Horarios de chequeo
- contacts_nagios.cfg ->Contactos a notificar

3.- Ejemplo contenido nodos_nagios.cfg:

define host{
     hostgroups server-web
     host_name nagios
     alias Servidor Virtual
     address 127.0.0.1
     check_command check-host-alive
     max_check_attempts 5
     check_period 24x7
     check_interval 5
     retry_interval 1
}

define host{
     hostgroups server-datos
     host_name mariadb
     alias Servidor Fisico
     address xxx.xxx.xxx.xxx
     check_command check-host-alive
     max_check_attempts 5
     check_period 24x7
     check_interval 5
     retry_interval 1
}

define host{
     hostgroups server-web
     host_name debian
     alias Servidor Fisico
     address xxx.xxx.xxx.xxx
     check_command check-host-alive
     max_check_attempts 5
     check_period 24x7
     check_interval 5
     retry_interval 1
}

4.- Ejemplo contenido grupos_nagios.cfg:

define hostgroup {
     hostgroup_name  server-web
     alias           Linux Server
     members         debian, nagios
}

define hostgroup {
     hostgroup_name  server-datos
     alias           Linux Server
     members         mariadb
}

5.- Ejemplo contenido servicios_nagios.cfg:

# check that web services are running
define service {
     hostgroup_name                 server-web
     service_description            HTTP
     check_command                  check_http
     use                            generic-service
     notification_interval          0 ; set > 0 if you want to be renotified
}

# check that ssh services are running
define service {
     hostgroup_name                 server-web
     service_description            SSH
     check_command                  check_ssh
     use                            generic-service
     notification_interval          0 ; set > 0 if you want to be renotified
}

# check that mysql services are running
define service {
     hostgroup_name                 server-datos
     service_description            mysql
     check_command                  check_mysql
     use                            generic-service
     notification_interval          0 ; set > 0 if you want to be renotified
}

6.- Ejemplo contenido template.cfg:

# Generic contact definition template - This is NOT a real contact, just a template!

define contact{
     name                            generic-contact        ; The name of this contact template
     service_notification_period     24x7            ; service notifications can be sent anytime
     host_notification_period        24x7            ; host notifications can be sent anytime
     service_notification_options    w,u,c,r,f,s        ; send notifications for all service states, flapping events, and scheduled downtime events
     host_notification_options       d,u,r,f,s        ; send notifications for all host states, flapping events, and scheduled downtime events
     service_notification_commands   notify-service-by-email    ; send service notifications via email
     host_notification_commands      notify-host-by-email    ; send host notifications via email
     register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}

# HOST TEMPLATES
# Generic host definition template - This is NOT a real host, just a template!

define host{
     name                            server-web  ; The name of this host template
     notifications_enabled           1           ; Host notifications are enabled
     event_handler_enabled           1           ; Host event handler is enabled
     flap_detection_enabled          1           ; Flap detection is enabled
     failure_prediction_enabled      1           ; Failure prediction is enabled
     process_perf_data               1           ; Process performance data
     retain_status_information       1           ; Retain status information across program restarts
     retain_nonstatus_information    1           ; Retain non-status information across program restarts
     notification_period             24x7        ; Send host notifications at any time
     register                        0           ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

define host{
     name                            server-datos ; The name of this host template
     notifications_enabled           1           ; Host notifications are enabled
     event_handler_enabled           1           ; Host event handler is enabled
     flap_detection_enabled          1           ; Flap detection is enabled
     failure_prediction_enabled      1           ; Failure prediction is enabled
     process_perf_data               1           ; Process performance data
     retain_status_information       1           ; Retain status information across program restarts
     retain_nonstatus_information    1           ; Retain non-status information across program restarts
     notification_period             24x7        ; Send host notifications at any time
     register                        0           ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

# SERVICE TEMPLATES
# Generic service definition template - This is NOT a real service, just a template!

define service{
     name                            generic-service ; The 'name' of this service template
     active_checks_enabled           1               ; Active service checks are enabled
     passive_checks_enabled          1               ; Passive service checks are enabled/accepted
     parallelize_check               1               ; Active service checks should be parallelized (disabling this can lead to major performance problems)
     obsess_over_service             1               ; We should obsess over this service (if necessary)
     check_freshness                 0               ; Default is to NOT check service 'freshness'
     notifications_enabled           1               ; Service notifications are enabled
     event_handler_enabled           1               ; Service event handler is enabled
     flap_detection_enabled          1               ; Flap detection is enabled
     failure_prediction_enabled      1               ; Failure prediction is enabled
     process_perf_data               1               ; Process performance data
     retain_status_information       1               ; Retain status information across program restarts
     retain_nonstatus_information    1               ; Retain non-status information across program restarts
     is_volatile                     0               ; The service is not volatile
     check_period                    24x7            ; The service can be checked at any time of the day
     max_check_attempts              3               ; Re-check the service up to 3 times in order to determine its final (hard) state
     normal_check_interval           10              ; Check the service every 10 minutes under normal conditions
     retry_check_interval            2               ; Re-check the service every two minutes until a hard state can be determined
     contact_groups                  admins          ; Notifications get sent out to everyone in the 'admins' group
     notification_options        w,u,c,r             ; Send notifications about warning, unknown, critical, and recovery events
     notification_interval           60              ; Re-notify about service problems every hour
     notification_period             24x7            ; Notifications can be sent out at any time
     register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

7.- Ejemplo contenido timeperiods_nagios.cfg:

# This defines a timeperiod where all times are valid for checks,

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
}

# Here is a slightly friendlier period during work hours
define timeperiod{
     timeperiod_name workhours
     alias           Standard Work Hours
     monday          07:30-16:00
     tuesday         07:30-16:00
     wednesday       07:30-16:00
     thursday        07:30-16:00
     friday          07:30-16:00
}

# The complement of workhours
define timeperiod{
     timeperiod_name nonworkhours
     alias           Non-Work Hours
     sunday          00:00-24:00
     monday          00:00-07:30,16:00-24:00
     tuesday         00:00-07:30,16:00-24:00
     wednesday       00:00-07:30,16:00-24:00
     thursday        00:00-07:30,16:00-24:00
     friday          00:00-07:30,16:00-24:00
     saturday        00:00-24:00
}

define timeperiod{
     timeperiod_name never
     alias           Never
}

8.- Ejemplo contenido contacts_nagios.cfg:

# CONTACTS

define contact{
     contact_name                    root
     alias                           Root
     service_notification_period     24x7
     host_notification_period        24x7
     service_notification_options    w,u,c,r
     host_notification_options       d,r
     service_notification_commands   notify-service-by-email
     host_notification_commands      notify-host-by-email
     email                           nagios@localhost
}

# CONTACT GROUPS

define contactgroup{
     contactgroup_name       nagiosadmins
     alias                   Nagios Administrators
     members                 nagios
}

9.- Reiniciar el servicios de Nagios:

operador@servidor:/~$ sudo /etc/init.d/nagios3 restart

10.- Acceder al servicio de Nagios:

http://direccion_ip/nagios3/
Anuncios

3 comentarios en “Nagios 3.0 – Instalación y Configuración

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s