DevOps

LAB 9: Installing and Configuring PNP4Nagios

DevOps

LAB 9: Installing and Configuring PNP4Nagios

Step 1: installing and configuring PNP4Nagios

yum install rrdtool
yum install ruby xorg-x11-fonts-Type1 php-xml

Step 2: Downloading PNP4Nagios

cd /tmp/
wget https://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.25.tar.gz
tar -xvf pnp4nagios-0.6.25.tar.gz
cd pnp4nagios-0.6.25
./configure --with-rrdtool=/usr/bin/rrdtool --with-nagios-user=nagios --with-nagios-group=nagcmd
make all
make install-webconf
make install-config
make install-init
make fullinstall

Step 3: Start and Enable web & nagios service

systemctl enable npcd
systemctl start npcd
systemctl restart nagios
systemctl restart httpd

Step 4: Verify PNP4Nagios configuration

cd scripts
./verify_pnp_config_v2.pl -m bulk -c /usr/local/nagios/etc/nagios.cfg -p /usr/local/pnp4nagios/etc/

Step 5: Edit vi /usr/local/nagios/etc/nagios.cfg file add add below lines at the end

# service performance data
#
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 performance data starting with Nagios 3.0
#
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`

Step 6: Change below value from 0 to 1

process_performance_data=1
enable_environment_macros=1

Step 7: Error 1 – [CRIT] Command process-service-perfdata-file is not defined

vi /usr/local/nagios/etc/objects/commands.cfg

define command{
       command_name    process-service-perfdata-file
       command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
}

define command{
       command_name    process-host-perfdata-file
       command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
}
yum install php-xml

Step 8: Error 2 – sizeof(): Parameter must be an array or an object that implements Countable

vi /usr/local/pnp4nagios/share/application/models/data.php
Default line number: 979

Change from
if(sizeof($pages) > 0 ){

To
/*if(sizeof($pages) > 0 ){*/
   if(is_array($pages)&&sizeof($pages) > 0){

systemctl restart httpd
systemctl restart nagios

Step 9: Error 3

Deprecated Methods v/ith the same name as the r class «ni not De constructors in a future version of PHP Servlces_JSON has a deprecated constructor ‘usr local pnp4nagios share applications ison.php on line 115 Deprecated Methods with the same name as the« class nH not be constructors in a future version of PHP Services_JSON_Error has a deprecated constructor in ‘usr>local’pnp4nagios>’share application/lib json.php on line 781 Deprecated Methods with the same name as the« class w not be constructors in a future version of PHP Services_JSON_Errot has a deprecated constructor in ‘usr’local’pnp4nagios’Share application/lib json.php on line 795

vi /usr/local/pnp4nagios/share/application/lib/json.php

From
class Services_JSON
To
class _Services_JSON

From
class Services_JSON_Error extends PEAR_Error
To
class _Services_JSON_Error extends PEAR_Error

From
class Services_JSON_Error
To
class _Services_JSON_Error
rm -rf /usr/local/pnp4nagios/share/install.php

Step 10: Define a service to “ping” the local machine

vi /usr/local/nagios/etc/objects/localhost.cfg

define service {

    use                                                           local-service           ; Name of service template to use
    host_name                                             localhost
    service_description                              PING
    check_command                                  check_ping!100.0,20%!500.0,60%
    action_url       /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
}

systemctl restart httpd
systemctl restart nagios

Step 11: Open Browser