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:
Extract & Install PNP4Nagios:
# 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:
#
# 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
Edit commands.cfg and add following lines at last:
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
}
Edit “templates.cfg” and add following in Generic-host and Generic-service portions as:
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$
copy the file status-header.ssi from pnp4nagios package in /usr/local/src: < IT MUST NOT BE EXECUTEABLE…!!!>
Edit PNP4nagios.conf file in HTTPD directory:
And Set following value:
Restart Services:
# systemctl restart httpd.service
# service nagios restart
# service npcd start
# chkconfig npcd on
Now in Browser:::
– If no error shown, remove or rename the file “install.php”
Now Restart Nagios, HTTPD and NPCD Services again, PNP4Nagios should now be showing graphs like:
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
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
I have resolved the issue.
Thank you.
You just saved my job.