
En esta segunda parte vamos a añadir nuestros dispositivos a monitorizar a NAGIOS, esto es un proceso manual, que requiere conocer el editor de texto 'vi' o similar.
Estos ficheros, uno por maquina, tienen definidos los servicios a monitorizar.
Una vez creado uno, simplemente realizaremos copias cambiando lo necesario.
La ubicación de los ficheros de configuración es la definida en el fichero
/usr/local/nagios/etc/nagios.cfg
En la variable: '
cfg_dir ='
Si seguiste la primera parte de este procedimiento, des comentaste la variable 'cfg_dir=', dejando la ruta por defecto que por lo tanto es:
Servidores
/usr/local/nagios/etc/servers
Printers
/usr/local/nagios/etc/objects
Dentro de estas rutas, crearemos un fichero con el nombre del host a monitorizar y extensión .cfg
Para facilitar el proceso, dejo un fichero de configuración de servidor y otro de impresoras, pero ojo, el metodo de monitorización que usemos para cada servicio puede variar, yo he optado por la instalación de plugin NSClient++ en cada maquina windows para recopilar información.
Descargar NSClient++ en su versión 32 o 64bit segun sea necesario desde el website oficial: http://www.nsclient.org/
Este es el contenido del fichero 'srvficheros1.cfg'
Ubicación:
/usr/local/nagios/etc/servers/srvficheros1.cfg
###############################################################################
# WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE
#
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Nagios quickstart guide.
#
###############################################################################
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################
# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation
define host{
use windows-server
host_name srcrm
icon_image win40.png
alias PreviAPPS/SUGAR/Ticketing
address 192.168.110.57
}
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################
# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of this group
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################
# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name srcrm
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above
define service {
use generic-service
host_name srcrm
service_description Uptime
check_command check_nt!UPTIME
}
# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name srcrm
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name srcrm
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name srcrm
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service
host_name srcrm
service_description E:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l e -w 80 -c 90
}
# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name srcrm
service_description Apache
check_command check_nt!SERVICESTATE!-d SHOWALL -l Apache2.2
}
# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above
#define service{
# use generic-service
# host_name srdc1
# service_description TermService
# check_command check_nt!PROCSTATE!-d SHOWALL -l TermService
# }
# Check WebSites
define service{
use generic-service
host_name srcrm
service_description SUGAR WebSite
check_command check_http!-u http://192.168.110.57/sugar -w 303 -c 404
}
}
En esta maquina, monitorizamos:
- Tiempo uptime del servidor.
- Carga de la CPU
- Carga de la memoria RAM
- Espacio ocupado y libre en los discos C: y E:
- Que los servicios 'explorer' y TermService'' (Terminal Server) están levantados.
- Que la web 'http://192.168.110.57/sugar' este levantada.
Los margenes usados para considerar los estados de WARRING o CRITIAL son:
Ocupación de disco duro/memoria, menor del 79% = Estado OK
Ocupación de disco duro/memoria, entre el 80% y el 89% = Estado WARNIG
Ocupación de disco duro/memoria, superior al del 90% = Estado CRITIAL
Tras la creación de cada ficheros, tenemos que realizar una refresco del servicio NAGIOS para que muestre los cambios. Esto lo realizaremos con un 'sudo service nagios reload' desde la terminal.
A continuación os dejo el contenido del ficheros printer.cfg donde he añadido dos impresoras a las que solo monitorizamos por ping la disponibilidad.
Ubicación:
/usr/local/nagios/etc/objects/printer.cfg
###############################################################################
# PRINTER.CFG - SAMPLE CONFIG FILE FOR MONITORING A NETWORK PRINTER
#
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Nagios quickstart guide.
#
###############################################################################
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################
# Define a host for the printer we'll be monitoring
# Change the host_name, alias, and address to fit your situation
define host{
use generic-printer ; Inherit default values from a template
host_name XeroxWorkCentre4250 ; The name we're giving to this printer
icon_image hp-printer40.png
alias Xerox WorkCentre 4250 ; A longer name associated with the printer
address 192.168.110.16 ; IP address of the printer
hostgroups network-printers ; Host groups this printer is associated with
}
define host{
use generic-printer
host_name XeroxWorkCentre3550
icon_image hp-printer40.png
alias Xerox WorkCentre 3550
address 192.168.110.15
hostgroups network-printers
}
define host{
use generic-printer
host_name XeroxWorkCentre7545
icon_image hp-printer40.png
alias Xerox WorkCentre 7545
address 192.168.110.13
hostgroups network-printers
}
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################
# A hostgroup for network printers
define hostgroup{
hostgroup_name network-printers ; The name of the hostgroup
alias Network Printers ; Long name of the group
}
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################
# Create a service for monitoring the status of the printer
# Change the host_name to match the name of the host you defined above
# If the printer has an SNMP community string other than "public", change the check_command directive to reflect that
#define service{
# use generic-service ; Inherit values from a template
# host_name XeroxWorkCentre4250 ; The name of the host the service is associated with
# service_description Printer Status ; The service description
# check_command check_hpjd!-C public ; The command used to monitor the service
# normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
# retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
# }
# Create a service for "pinging" the printer occassionally. Useful for monitoring RTA, packet loss, etc.
define service{
use generic-service
host_name XeroxWorkCentre4250
service_description PING
check_command check_ping!3000.0,80%!5000.0,100%
normal_check_interval 10
retry_check_interval 1
}
define service{
use generic-service
host_name XeroxWorkCentre3550
service_description PING
check_command check_ping!3000.0,80%!5000.0,100%
normal_check_interval 10
retry_check_interval 1
}
define service{
use generic-service
host_name XeroxWorkCentre7545
service_description PING
check_command check_ping!3000.0,80%!5000.0,100%
normal_check_interval 10
retry_check_interval 1
}
Termino esta segunda parte del tutorial animando a todos a que entréis en el mundo de los plugin de NAGIOS, existen una gran cantidad de ellos que nos permiten monitorizar diferentes estados, como la temperatura de la placa base y microprocesador de un servidor, la carga de los puertos de red de un switch o router, o incluso la reserva de cada cartuchos de color de tinta de una impresora.
Nos vemos en una tercera parte sobre las notificaciones por email.





0 comentarios:
Publicar un comentario