Installing PNP4Nagios on CentOS

1. Nagios is ready

Make sure nagios is ready; nagios plugins and nrpe are installed.

2. Install rrdtool

rrdtool is necessary for storing nagios data, and used to draw graph be pnp4nagios.Current version of rrdtool is 1.4.7, but installs it by yum only get 1.3.8. So, have to manually install 1.4.7. Download the required RPMS and install it [root@nagios~]# wget [root@nagios~]# wget [root@nagios~]# rpm -ivh rrdtool-1.4.7-1.el6.rfx.i686.rpm perl-rrdtool-1.4.7-1.el6.rfx.i686.rpm

2.1 Install related libs

[root@nagios~]# yum install libdbi 1 [root@nagios~]# yum install ruby xorg-x11-fonts-Type1 3

2.3 Test rrdtool

rrdtool is ready to use, but have to verify that if it is functioning properly. [root@nagios~]# rrdtool -v 4 It shows rrdtool version is 1.4.7. Go to examples folder. [root@nagios~]# cd /usr/share/rrdtool/examples Run the perl script to create a demo png. [root@nagios~]# ./ [root@nagios~]#cp stripes.png /var/www/html View the png in browser:  http://ip/stripes.png


3. Install pnp4nagios

3.1 Download the latest version

# wget [root@nagios~]#tar -zxvf pnp4nagios-0.6.21.tar.gz [root@nagios~]# cd  pnp4nagios-0.6.21 [root@nagios~]#./configure –prefix=/usr/share/pnp4nagios –with-rrdtool=/usr/bin/rrdtool –with-nagios-user=nagios –with-nagios-group=nagios 5

3.2 Compile and install

[root@nagios~]# make all && make install && make install-webconf && make install-config && make install-init Make sure no errors shown up. 3.3 Rename cfg files

[root@nagios~]# cd   /usr/share/pnp4nagios/etc 
[root@nagios~]# mv misccommands.cfg-sample  misccommands.cfg 
[root@nagios~]# mv nagios.cfg-sample nagios.cfg 
[root@nagios~]# mv rra.cfg-sample rra.cfg 
[root@nagios~]# cd /usr/share/pnp4nagios/etc/pages/ 
[root@nagios~]# mv web_traffic.cfg-sample web_traffic.cfg 
[root@nagios~]# cd ../check_commands 
[root@nagios~]# mv check_all_local_disks.cfg-sample  check_all_local_disks.cfg 
[root@nagios~]# mv check_nrpe.cfg-sample  check_nrpe.cfg 
[root@nagios~]# mv check_nwstat.cfg-sample  check_nwstat.cfg

3.4 Set up npcd service
Set npcd service to automatically start when system boot.

[root@nagios~]# chkconfig --add npcd
[root@nagios~]# chkconfig npcd on
[root@nagios~]# service npcd start

3.5 Test pnp4nagios

Type in http://server-ip/pnp4nagios to test result.

And then remove the install file as:
[root@nagios~]# rm /usr/share/pnp4nagios/share/install.php

3.6 Set up bulk+npcd for pnp4nagios

 The mode of bulk+npcd is working for a good performance of nagios.
 [root@nagios~]# vi /usr/local/nagios/etc/nagios.cfg

Add or UN-comment below lines:
# service performance data

# host performance data starting with Nagios 3.0

3.7 Modify commands.cfg

A command is unique, a duplicated command would cause a nagios syntax error.
[root@nagios~]# vi /etc/nagios/objects/misccommands.cfg
 Change the command_line as below:
define command{
command_name    process-service-perfdata-file
command_line    /bin/mv /usr/share/pnp4nagios/var/service-perfdata /usr/share/pnp4nagios/var/spool/service-perfdata.$TIMET$

The command_name is defined in both of nagios.cfg and commands.cfg, the command_name have to be matched in the two files. And then reload nagios: [root@nagios~]#service nagios reload

3.8 Verify pnp4nagios configuration

It is hard to identify if the settings of pnp4nagios are all correct, the messages in log
file usually are not easy to understand. Fortunately, a verify script is available to 
complete this task. 

Download the perl script "verify_pnp_config" to verify configuration.
# wget

Run the script to verify.
# perl verify_pnp_config –mode bulk+npcd –config=/usr/local/nagios/etc/nagios.cfg –pnpcfg=/usr/share/pnp4nagios/etc

The verification is passed, and performance data is shown as well, it means all settings are correct. Otherwise, have to fix any critical errors before go forward. Go to http://server-ip/pnp4nagios again, it shows some graphs 8

3.9 Integrated with Nagios

Since nagios 3.0, the action_url-directive has be moved to the host or service definition. Only need to modify the definition of action URLs to show PNP-interface. Two nagios templates are defined to create hosts and services, host-templates.cfg and service-templates.cfg, which will use action-url. Create a new host-pnp in host-templates.cfg: define host { name       host-pnp action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_ register   0 } And create a new srv-pnp in service-templates.cfg: define service { name                srv-pnp action_url      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ register   0 } These two templates can now be included via “use srv-pnp” or “use host-pnp” for services and hosts respectively. In the hosts.cfg and services.cfg, add “use host-pnp” and “use srv-png as below.

define host{
use         linux-server,host-pnp          ; Name of host templates to use
                                           ; host definition will inherit all variables that are defined
                                           ; in (or inherited by) the linux-server host template 

host_name              localhost
alias                  localhost
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%

Restart nagios, the links to the correct URLs are created automatically. 9 The action icon is shown in the nagios pane, but the icon should indicate that is a pnp graph. Change the image of the icon for better showing. # cd /usr/local/nagios/share/images # cp trends.gif action.gif The icon looks nice after the browser reload. Clicking at the icon would show up pnp graphs. 10 By default, pnp graphs would be opened in a new window, but if it is shown in the main frame would be a better feeling for users. This could be changed in cgi.cfg file. # vim /usr/local/nagios/etc/cgi.cfg Change “action_url_target = main”, save and reload nagios, the result is shown as below. 11

3.10 Popups pnp graphs

When move over the mouse on the icon, a pnp graph is popup, it is a very cool feeling for users. Some changes should be applied to action_url. First, need to copy ssi( server side include) from pnp4nagios install folder to nagios folder. # cp download/php4nagios-head/contrib/ssi/* /usr/local/nagios/share/ssi Second, modify the action_url in host-pnp and srv-pnp as below.

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

The installation and configuration of pnp4nagios are completed.

About Manish Jha

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Monitoring. Bookmark the permalink.

5 Responses to Installing PNP4Nagios on CentOS

  1. Installing PNP4Nagios on CentOS | Linux/Vmware Solutions


  2. GregW says:

    big shout out for this – thanks very much – helped me troubleshoot my install big time.

    in 3.8 you call out
    # perl verify_pnp_config –mode bulk+npcd –config=/usr/local/nagios/nagios/nagios.cfg –pnpcfg=/usr/share/pnp4nagios/etc

    should be
    # perl verify_pnp_config –mode bulk+npcd –config=/usr/local/nagios/etc/nagios.cfg –pnpcfg=/usr/share/pnp4nagios/etc


  3. sharing says:

    Undeniably consider that which you said. Your favourite reason appeared to be on the net the
    easiest thing to take note of. I say to you, I certainly
    get annoyed even as people consider worries that they
    just do not know about. You managed to hit the nail
    upon the highest as neatly as defined out the whole thing without having side effect , people can take a signal.

    Will likely be again to get more. Thank you


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s