Wednesday , December 19 2018
Home / Network Admin / Installing PNP4Nagios for Nagios on CentOS

Installing PNP4Nagios for Nagios on CentOS

In this tutorial, I’ll be installing PNP4Nagios for Nagios to draw graphs on Nagios NMS Server’s Web UI.

Download PNP4Nagios:

http://downloads.sourceforge.net/project/pnp4nagios/

Installing Required Dependencies:

# yum -y install rrdtool rrdtool-perl php-gd perl-Time-HiRes libtool-ltdl rrdtool-devel php-rrdtool perl-rrdtool php php-pdo php-common

 

Extract & Install PNP4Nagios:

# cd /usr/local/src
# wget http://downloads.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.24.tar.gz
# tar zxvf pnp4nagios-0.6.24.tar.gz
# cd pnp4nagios-0.6.24
# ./configure
# make all
# make fullinstall

 

Edit Nagios.cfg, enable “process_performance_data” and add following lines at last:

 #  vim /etc/nagios/nagios.cfg
process_performance_data=1

#
# 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

2- Edit Nagios Config File  Installing PNP4Nagios for Nagios on CentOS 2 Edit Nagios Config File

Edit commands.cfg and add following lines at last:

# vim /etc/nagios/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
}

 

3- Edit Commands Config File  Installing PNP4Nagios for Nagios on CentOS 3 Edit Commands Config File

 

Edit “templates.cfg” and add following in Generic-host and Generic-service portions as:

# vim /etc/nagios/objects/templates.cfg
Add following line in “generic-host” portion:

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_’ class=’tips’ rel=’/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_

Add following line in “generic-service” portion:

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$’ class=’tips’ rel=’/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$

 

4- Edit Templates Config File  Installing PNP4Nagios for Nagios on CentOS 4 Edit Templates Config File

 

copy the file status-header.ssi from pnp4nagios package in /usr/local/src: < IT MUST NOT BE EXECUTEABLE…!!!>

# cp /usr/local/src/pnp4nagios-0.6.24/contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/

 

Edit PNP4nagios.conf file in HTTPD directory:

# vim /etc/httpd/conf.d/pnp4nagios.conf

And Set following value:

AuthUserFile /etc/nagios/htpasswd.users

5- Edit PnP4Nagios Config File  Installing PNP4Nagios for Nagios on CentOS 5 Edit PnP4Nagios Config File

 

Restart Services:

# service httpd restart
# systemctl restart httpd.service
# service nagios restart
# service npcd start
# chkconfig npcd on

Now in Browser:::

   http://ipaddress/pnp4nagios

6- Pnp4Nagios Test Pass  Installing PNP4Nagios for Nagios on CentOS 6 Pnp4Nagios Test Pass
– If no error shown, remove or rename the file “install.php”

# mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.org

7- Install File Rename  Installing PNP4Nagios for Nagios on CentOS 7 Install File Rename

Now Restart Nagios, HTTPD and NPCD Services again, PNP4Nagios should now be showing graphs like:

 

8- Pnp4Nagios Graphs Working  Installing PNP4Nagios for Nagios on CentOS 8 Pnp4Nagios Graphs Working

7.5- Pnp4Nagios Working  Installing PNP4Nagios for Nagios on CentOS 7

About Muhammad Attique

Check these out :)

How to Modify GRUB Bootloader version 2

I’m going to show you how can we edit and modify GRUB Bootloader version 2, …

4 comments

  1. Hi Muhmmad, thank you for this great job you’ve done here !!!

    I am a newbie in linux system, do you have others tutorial to define the services as the pictures in your tutorial ? like cpu, free space disk, ram, etc… with graph with pnp4Nagios

    thanks again

  2. Assalamu Alaikum Muhammad, Thanks for your wonderful article.

    I have successfully installed pnp4nagios but I have a small query. In nagios tool, I could find graph icon under services tab but the graph icon is showing under hosts tab..What would be the issue? Thanks in advance

  3. Thank you.

    You just saved my job.

Leave a Reply

Your email address will not be published. Required fields are marked *