How to Install and configure Pnp4Nagios Bulk+NPCD Mode with Nagios4.x Centos 7.x

PNP4NAGIOS:-

Pnp4Nagios works with Nagios to generate the graph of services that are being monitored by Nagios server. With the help of Pnp4Nagios, we can see the graph anytime whenever needed,  It record graph for all the configured services, We can view usage like CPU, RAM, Disk Space etc.

Prerequisites:  

1- RRDTOOL, rrdtool-perl
2- Perl
3- Php-gd
4- perl-time-HiRes

Step 1-  Installation
To Install prerequisites run below command
[root@localhost ~]# yum install rrdtool perl-Time-HiRes rrdtool-perl php-gd

Once prerequisites installation done, download pnp4nagios.
Step 2- Download PNP4Nagios, Extract and Install
[root@localhost ~]# wget https://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.25.tar.gz
Once download get finished, extract package using command below
[root@localhost ~]# tar zxfv pnp4nagios-0.6.25.tar.gz
Go to the Extracted directory and configure it.
[root@localhost ~]# cd pnp4nagios-0.6.25
Configure pnp4nagios and install using command below
[root@localhost pnp4nagios]# ./configure
[root@localhost pnp4nagios]# make all
[root@localhost pnp4nagios]# make fullinstall

Enable NPCD service to start at boot time and start it now.
[root@localhost ~]# chkconfig --add npcd && chkconfig --level 35 npcd on

Let's reboot httpd service.
[root@localhost ~]# systemctl restart httpd

Step 2- Let's check PNP4Nagios installation.

Open browser and type URL:- 192.168.102.11/pnp4nagios/











































After successful PNP4Nagios installation, you will get the window like above.

Step 3- Let's rename install.php to install.php-bak
[root@localhost ~]# mv  /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php-bak

Step 4-  Make the required changes in Nagios configuration to integrate PNP4Nagios to generate graph.

Make the changes in nagios.cfg configuration file.
[root@localhost ~]# vi /usr/local/nagios/etc/nagios.cfg
Change the Process_performance_data=1 and append below mentions line.
# Bulk / NPCD mode
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$\tSERVICECH$
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::$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
Save and exit from file.
Now make the required changes in command.cfg file
[root@localhost ~]# vi /usr/local/nagios/etc/objects/commands.cfg
Go to the end of file and append the red line below and comment all the black line.
# 'process-host-perfdata' command definition
#define command{
# command_name process-host-perfdata
# command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out
# }


# 'process-service-perfdata' command definition
#define command{
# command_name process-service-perfdata
# command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out
# }

# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$$
}

# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$$
}

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$
}



Let's make change in template.cfg file 
[root@localhost ~]# vi /usr/local/nagios/etc/objects/templates.cfg
Append the red line in the below of file.
# PNP4NAGIOS #
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

Save and Exit from file

Now make the change in the host configuration fiel
[root@localhost ~]# vi /usr/local/nagios/etc/objects/localhost.cfg

Append the following lines in the end of file.
# Define a host for the local machine

define host{
use linux-server,host-pnp ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name localhost
alias localhost
address 127.0.0.1
}



# Define a service to "ping" the local machine




define service{


        use                             local-service,srv-pnp         ; Name of service template to use


        host_name                       localhost


        service_description             PING


        check_command                   check_ping!100.0,20%!500.0,60%


        }



Save and exit from file.

All the configuration changed completed successfully.

Step 5-  Now restart httpd, Nagios and Npcd service using command below.
[root@localhost ~]# systemctl restart httpd && systemctl restart nagios && systemctl restart npcd

Step 6- Verify integration of PNP4Nagios

Open Nagios server URL:-  http://192.168.102.11/nagios/

After successful integration of PNP4nagios you get a graph symbol for each service like in below image:







And you will see graph for individual service image like below:























Congratulation!!! Installation and Integration of PNP4Nagios with Nagios server completed successfully done with Bulk+NPCD mode.