Author Photo

Being a Linux Enthusiast and a Fan of Open Source Software, I created Ahmer’s SysAdmin Recipes blog to share my experiences with other System Administrators. The curiosity doesn’t let me stop; therefore, I am constantly trying to learn new software tools and techniques. Whereas I also have the passion and the patience to teach the others.

I am always ready to accept new challenges and wish to explore the areas, that I haven’t worked on. Please give me your feedback and help me improve this blog.

Sunday, 4 September 2016

Install PNP4Nagios on Nagios Core over CentOS 7

pnp4nagios-install-to-nagios-core-on-centos-6In search of a graph add-on for Nagios, we have already explored the Nagiosgraph, although it works fine. But we kept looking for other alternates to Nagiosgraph. This is how PNP4Nagios pulls our attention towards it. PNP4Nagios is an add-on to Nagios which analyzes performance data provided by plugins and stores them automatically into RRD-databases (Round Robin Databases).

PNP4Nagios can be configured in different ways like SYNC, BULK, BULK+NPCD, etc. Although the SYNC mode is claimed to has the most straight forward configurations, but unfortunately it didn’t work for me due to some bug (related to Environment Variables) in Nagios 4.x. Therefore, I switched to BULK+NPCD mode.

In this article, we will install PNP4Nagios plugin on our Nagios Core Server over CentOS 7.

Before moving forward, it is required to have basic concepts of Nagios Core 4. Therefore, it is highly recommended that you should have Learning Nagios - Third Edition. It will be really helpful for you during your Nagios journey.

 

System Specification:

We have configured a CentOS 7 virtual machine with Nagios Core 4.4 Server having following specifications.

CPU: 2.4 Ghz (1 Core)
Memory: 1 GB
Storage: 20 GB
Swap: 2 GB
Operating System: CentOS 7.6
Nagios Version: Nagios Core 4.4
IP Address: 192.168.229.131/24

Read Also: Install & Configure Nagios Core 4.2 on CentOS 6
  Install & Configure Nagios Core 4.4 on CentOS 7

 

Install PNP4Nagios on Nagios Core over CentOS 7:

Install prerequisites packages using yum.

[root@nagios02 nagios]# yum install rrdtool rrdtool-perl perl-Time-HiRes perl-GD -y

Download the latest tarball of PNP4Nagios from http://www.pnp4nagios.org/.

Go to the directory in which you have downloaded the PNP4Nagios tarball, and extract it.

[root@nagios02 ~]# cd /soft/nagios [root@nagios02 nagios]# tar xvf pnp4nagios-0.6.25.tar.gz

Go the directory, where PNP4Nagios is extracted, and install it.

[root@nagios02 nagios]# cd pnp4nagios-0.6.25 [root@nagios02 pnp4nagios-0.6.25]# ./configure [root@nagios02 pnp4nagios-0.6.25]# make all [root@nagios02 pnp4nagios-0.6.25]# make fullinstall

Edit nagios.cfg and comment (#) all performance parameters.

[root@nagios02 pnp4nagios-0.6.25]# vi /usr/local/nagios/etc/nagios.cfg

Add following parameters in 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 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

Now edit commands.cfg.

[root@nagios02 pnp4nagios-0.6.25]# vi /usr/local/nagios/etc/objects/commands.cfg

Add following commands in commands.cfg.

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

Start and enable npcd service.

[root@nagios02 pnp4nagios-0.6.25]# /usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg [root@nagios02 pnp4nagios-0.6.25]# systemctl enable npcd.service

Restart nagios and httpd services.

[root@nagios02 pnp4nagios-0.6.25]# systemctl restart nagios.service [root@nagios02 pnp4nagios-0.6.25]# systemctl restart httpd.service

Open the URL http://192.168.229.131/pnp4nagios in a client's browser to check configurations, and if there is a failed check then rectify it. (Change the IP address to your CentOS 7 server’s IP address here.)

PNP4Nagios-Environment-Test

It didn’t show me any failure.

Now remove the file /usr/local/pnp4nagios/share/install.php

[root@nagios02 ~]# rm -f /usr/local/pnp4nagios/share/install.php

Again, open the URL http://192.168.229.131/pnp4nagios in a client's browser and this time you will see the graphs.

PNP4Nagios-Graphs

We have successfully installed PNP4Nagios plugin on our Nagios Core Server over CentOS 7.

Install PNP4Nagios on Nagios Core over CentOS 7


YOU MIGHT ALSO LIKE:

9 comments:

  1. Sound Achievement. Its really good.

    ReplyDelete
  2. Thank you, working with new 4.2.1 too.

    ReplyDelete
  3. Hello , thanks for the tuto it work smoothly,
    There is a missing thing, that after installing pnp4nagios and it gave me all the wanted graphs, i can't export it as PDF and notice said that "php gd functions are missing", in my case I fixed it with installing php-gd wih the commande "yum install php-gd"
    maybe you can invoke it in the prerequisites packages.

    ReplyDelete
  4. Nice blog with excellent information. Thank you, keep sharing. Kubernetes Training in Hyderabad

    ReplyDelete
  5. Replies
    1. Hi,

      I haven't work on this scenario yet. On your request, I am adding it to the pipeline. Hopefully, you may find the required article on this Blog very soon.

      Delete