Usando Linux para muchas cosas y disfrutando de videojuegos, en dispositivos moviles, consolas y pc. Using Linux for many things and enjoying video games, mobile devices, consoles and pc

Como instalar PNP4Nagios

DriveMeca instalando PNP4Nagios en Nagios 4 en un servidor Linux Centos 7
Tienes Nagios para monitorear dispositivos y te gustaría poder graficar el desempeño de ellos? Bien, te presento PNP4Nagios, un plugin o complemento que analiza datos de desempeño y los almacena por medio de rrd (Round Robin Databases). Hoy te mostrare en este tutorial en español como instalar PNP4Nagios paso a paso, con screenshoots y de forma sencilla.

Requerimientos de PNP4Nagios en Linux Centos 7

-Instalamos dependencias

yum install rrdtool rrdtool-perl php-gd 

-Modificamos httpd.conf activando mod_rewrite

vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

-Descargamos y descomprimimos PNP4Nagios

wget -c http://downloads.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.25.tar.gz

-Descomprimimos el archivo y entramos a su directorio

tar xzvf pnp4nagios-0.6.25.tar.gz
cd pnp4nagios-0.6.25


Compilamos PNP4Nagios en Linux Centos 7

-Nos preparamos para compilar código

./configure
..
..
..
*** Configuration summary for pnp4nagios-0.6.25 03-01-2015 ***

  General Options:
  -------------------------         -------------------
  Nagios user/group:                nagios nagios
  Install directory:                /usr/local/pnp4nagios
  HTML Dir:                         /usr/local/pnp4nagios/share
  Config Dir:                       /usr/local/pnp4nagios/etc
  Location of rrdtool binary:       /bin/rrdtool Version 1.4.8
  RRDs Perl Modules:                FOUND (Version 1.4008)
  RRD Files stored in:              /usr/local/pnp4nagios/var/perfdata
  process_perfdata.pl Logfile:      /usr/local/pnp4nagios/var/perfdata.log
  Perfdata files (NPCD) stored in:  /usr/local/pnp4nagios/var/spool

  Web Interface Options:
  -------------------------         -------------------
  HTML URL:                         http://localhost/pnp4nagios
  Apache Config File:               /etc/httpd/conf.d/pnp4nagios.conf


  Review the options above for accuracy.  If they look okay,
  type 'make all' to compile.

-Compilamos

make all

-Instalamos

make fullinstall
..
..
..
*** Configuration summary for pnp4nagios-0.6.25 03-01-2015 ***

  General Options:
  -------------------------         -------------------
  Nagios user/group:                nagios nagios
  Install directory:                /usr/local/pnp4nagios
  HTML Dir:                         /usr/local/pnp4nagios/share
  Config Dir:                       /usr/local/pnp4nagios/etc
  Location of rrdtool binary:       /bin/rrdtool Version 1.4.8
  RRDs Perl Modules:                FOUND (Version 1.4008)
  RRD Files stored in:              /usr/local/pnp4nagios/var/perfdata
  process_perfdata.pl Logfile:      /usr/local/pnp4nagios/var/perfdata.log
  Perfdata files (NPCD) stored in:  /usr/local/pnp4nagios/var/spool

  Web Interface Options:
  -------------------------         -------------------
  HTML URL:                         http://localhost/pnp4nagios
  Apache Config File:               /etc/httpd/conf.d/pnp4nagios.conf



*** Main program, Scripts and HTML files installed ***

Enjoy.

-Activamos servicios httpd y npcd

systemctl enable npcd
systemctl restart httpd
systemctl start npcd

-Abrimos un browser y navegamos a http://192.168.1.10/pnp4nagios/ El sistema hará un chequeo y todo debe quedarnos en verde, en caso contrario debemos corregir para poder continuar
DriveMeca instalando PNP4Nagios en Nagios 4 en un servidor Linux Centos 7


-Ya instalado, renombramos el php de instalación y prevenimos que se use nuevamente por seguridad

mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/1234install.php
touch /usr/local/pnp4nagios/share/install.ignore
chown nagios.nagios /usr/local/pnp4nagios/share/install.ignore

-Recargamos la pagina en nuestro navegador

-Copiamos código del fichero pnp4nagios-0.6.25/sample-config/nagios.cfg-sample a nagios.cfg

vi /usr/local/nagios/etc/nagios.cfg
process_performance_data=1

service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata

service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$

service_perfdata_file_mode=a

service_perfdata_file_processing_interval=15

service_perfdata_file_processing_command=process-service-perfdata-file

host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata

host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$

host_perfdata_file_mode=a

host_perfdata_file_processing_interval=15

host_perfdata_file_processing_command=process-host-perfdata-file

-Copiamos código del fichero pnp4nagios-0.6.25/sample-config/misccommands.cfg-sample a commands.cfg

vi /usr/local/nagios/etc/objects/commands.cfg
#
# Bulk with NPCD mode
#
define command {
       command_name    process-service-perfdata-file
       command_line    /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$
}

define command {
       command_name    process-host-perfdata-file
       command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
}

-Definimos plantillas para hosts y servicios

vi /usr/local/nagios/etc/objects/templates.cfg
define host {
 name host-pnp
 action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
 register 0
}

define service {
 name srv-pnp
 action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
 register 0
}

-Usamos las plantillas con algún dispositivo o host recordando que para que funcione debemos tener definido process_performance_data=1, en este caso la plantilla de generic-host debe tenerlo activo, al igual seria con algún servicio.

vi /usr/local/nagios/etc/objects/templates.cfg
define host{
        name                            linux-server    
        use                             generic-host,host-pnp   
        check_period                    24x7            
        check_interval                  5               
        retry_interval                  1               
        max_check_attempts              10              
        check_command                   check-host-alive 
        notification_period             workhours                                                               
        notification_interval           120            
        notification_options            d,u,r           
        contact_groups                  admins          
        register                        0               
        }

-Copiamos
cp contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/
chown nagios.nagios /usr/local/nagios/share/ssi/status-header.ssi

-Algunos cambios necesarios
mkdir /var/lib/php/session
chown root.apache /var/lib/php/session
chmod 770 /var/lib/php/session/

-Reiniamos servicios
systemctl restart npcd
systemctl restart nagios

Verificamos configuracion de PNP4Nagios en Linux Centos 7

-Verificamos la configuracion de PNP4Nagios
cd /usr/local/pnp4nagios/bin
wget -c http://verify.pnp4nagios.org/verify_pnp_config

perl verify_pnp_config --mode bulk+npcd --config=/usr/local/nagios/etc/nagios.cfg --pnpcfg=/usr/local/pnp4nagios/etc
[INFO]  ========== Starting Environment Checks ============
[INFO]  My version is: verify_pnp_config-0.6.25-R.40
[INFO]  Start Options: verify_pnp_config --mode bulk+npcd --config=/usr/local/nagios/etc/nagios.cfg --pnpcfg=/usr/local/pnp4nagios/etc
[INFO]  Reading /usr/local/nagios/etc/nagios.cfg
[OK  ]  Running product is 'nagios'
[OK  ]  object_cache_file is defined
[OK  ]  object_cache_file=/usr/local/nagios/var/objects.cache
[INFO]  Reading /usr/local/nagios/var/objects.cache
[OK  ]  resource_file is defined
[OK  ]  resource_file=/usr/local/nagios/etc/resource.cfg
[INFO]  Reading /usr/local/nagios/etc/resource.cfg
[INFO]  Reading /usr/local/pnp4nagios/etc/process_perfdata.cfg
[INFO]  Reading /usr/local/pnp4nagios/etc/pnp4nagios_release
[OK  ]  Found PNP4Nagios version "0.6.25"
[OK  ]  Effective User is 'nagios'
[OK  ]  User nagios exists with ID '1002'
[OK  ]  Effective group is 'nagios'
[OK  ]  Group nagios exists with ID '1002'
[INFO]  ========== Checking Bulk Mode + NPCD Config  ============
[OK  ]  process_performance_data is 1 compared with '/1/'
[OK  ]  service_perfdata_file is defined
[OK  ]  service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
[OK  ]  service_perfdata_file_template is defined
[OK  ]  service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
[OK  ]  PERFDATA template looks good
[OK  ]  service_perfdata_file_mode is defined
[OK  ]  service_perfdata_file_mode=a
[OK  ]  service_perfdata_file_processing_interval is defined
[OK  ]  service_perfdata_file_processing_interval=15
[OK  ]  service_perfdata_file_processing_command is defined
[OK  ]  service_perfdata_file_processing_command=process-service-perfdata-file
[OK  ]  host_perfdata_file is defined
[OK  ]  host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
[OK  ]  host_perfdata_file_template is defined
[OK  ]  host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
[OK  ]  PERFDATA template looks good
[OK  ]  host_perfdata_file_mode is defined
[OK  ]  host_perfdata_file_mode=a
[OK  ]  host_perfdata_file_processing_interval is defined
[OK  ]  host_perfdata_file_processing_interval=15
[OK  ]  host_perfdata_file_processing_command is defined
[OK  ]  host_perfdata_file_processing_command=process-host-perfdata-file
[INFO]  Nagios config looks good so far
[INFO]  ========== Checking config values ============
[OK  ]  npcd daemon is running
[OK  ]  /usr/local/pnp4nagios/etc/npcd.cfg is used by npcd and readable
[INFO]  Reading /usr/local/pnp4nagios/etc/npcd.cfg
[OK  ]  perfdata_spool_dir is defined
[OK  ]  perfdata_spool_dir=/usr/local/pnp4nagios/var/spool
[OK  ]  -1 files found in /usr/local/pnp4nagios/var/spool
service_perfdata_file_processing_command at verify_pnp_config line 462.
[OK  ]  Command process-service-perfdata-file is defined
[OK  ]  '/bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$'
[OK  ]  Command looks good
host_perfdata_file_processing_command at verify_pnp_config line 462.
[OK  ]  Command process-host-perfdata-file is defined
[OK  ]  '/bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$'
[OK  ]  Command looks good
[OK  ]  Script /usr/local/pnp4nagios/libexec/process_perfdata.pl is executable
[INFO]  ========== Starting global checks ============
[OK  ]  status_file is defined
[OK  ]  status_file=/usr/local/nagios/var/status.dat
[INFO]  host_query =
[INFO]  service_query =
[INFO]  Reading /usr/local/nagios/var/status.dat
[INFO]  ==== Starting rrdtool checks ====
[OK  ]  RRDTOOL is defined
[OK  ]  RRDTOOL=/bin/rrdtool
[OK  ]  /bin/rrdtool is executable
[OK  ]  RRDtool 1.4.8  Copyright 1997-2013 by Tobias Oetiker <tobi@oetiker.ch>
[OK  ]  USE_RRDs is defined
[OK  ]  USE_RRDs=1
[OK  ]  Perl RRDs modules are loadable
[INFO]  ==== Starting directory checks ====
[OK  ]  RRDPATH is defined
[OK  ]  RRDPATH=/usr/local/pnp4nagios/var/perfdata
[OK  ]  Perfdata directory '/usr/local/pnp4nagios/var/perfdata' exists
[WARN]  1 hosts/services are not providing performance data
[WARN]  'process_perf_data 1' is set for 2 hosts/services which are not providing performance data!
[OK  ]  'process_perf_data 1' is set for 20 of your hosts/services
[INFO]  ==== System sizing ====
[OK  ]  19 hosts/service objects defined
[INFO]  ==== Check statistics ====
[WARN]  Warning: 2, Critical: 0
[WARN]  Checks finished...


Comprobamos PNP4Nagios

-Navegando a nuestra consola web de Nagios veremos unos nuevos iconos o botones, son los de PNP4Nagios
DriveMeca instalando PNP4Nagios en Nagios 4 en un servidor Linux Centos 7

-Si dejamos el cursor del mouse encima de uno de estos botones, PNP4Nagios nos mostrara en un popup un breve resumen
DriveMeca instalando PNP4Nagios en Nagios 4 en un servidor Linux Centos 7

-Y si damos click en el botón nos abrirá una nueva pagina con la información detallada en gráficas RRD. Esta la podemos exportar en PDF, ver en rangos de fechas y varias opciones útiles mas
DriveMeca instalando PNP4Nagios en Nagios 4 en un servidor Linux Centos 7


Artículos recomendadosMonitorea pfSense por medio de NRPE y Nagios
                                           Como instalar NRPE en Nagios paso a paso
                                           La guia FINAL de OCS Inventory en Centos 7
                                          Potencia tu Linux Centos e instala los repositorios RPMForge / Epel / Remi


Ya puedes mostrar tus gráficas de rendimiento y saber en todo momento el comportamiento de tus dispositivos monitoreados. Viendo esto planeas probar PNP4Nagios? ya lo usas? que tal te ha parecido?Te gusto el articulo? hazme un favor, compártelo en tus redes sociales (compartir es sexy). Escríbeme en los comentarios aquí debajo y pasa la voz compartiendo el tweet.

Sígueme en twitter google+facebook o email y podrás estar enterado de todas mis publicaciones.
Disfrútenlo.

Share/Bookmark

No hay comentarios:

Publicar un comentario

Dejame un comentario, aprecio la retroalimentacion. Leave me a comment, I appreciate the feedback.