Home » Categories » Products » Nagios Core » Documentation » Visualizations

Nagios Core - Performance Graphs Using PNP4Nagios

Nagios Core - Performance Graphs Using PNP4Nagios

This documentation explains how to configure Nagios Core to use the PNP4Nagios program to generate performance graphs.

When Nagios Core receives check results from Host and Service checks, the check result can include performance data. This performance data needs to be specifically formatted as per the following guidelines:

Nagios Plugins Development Guidelines - Performance Data

Nagios Core does not have it's own performance data engine built in to process this performance data, instead it provides functionality to pass this performance data to an external program that can store that data for later analysis.

PNP4Nagios is one such external program. PNP4Nagios provides the following functionality:

  • Process and store the received performance data in Round Robin Database (RRD) files
  • A GUI to display the data in the RRD files from within the Nagios Core interface
 
IMPORTANT

DO NOT follow this guide if you are using Nagios XI. Nagios XI includes a specific version and configuration of PNP4Nagios and following this guide will result in breaking your Nagios XI installation.

 

This guide is broken up into several sections and covers different Linux distributions and operating systems (OS). If your Linux Distribution or operating system is not included in this guide then please contact us to see if we can get it added. Some distributions may be missing as we don't have access to a test environment that allows us to develop the documentation.

PNP4Nagios 0.6.26 running on Nagios Core 4.3.4 is what this guide instructs you to install, however future versions should also work fine with these steps.

Note: This guide is based on Nagios Core being installed using the following KB article:

Documentation - Installing Nagios Core From Source

Because this guide is based on Nagios Core already being installed, prerequisites like Apache and PHP will already be installed on the Nagios Core server, they will only be re-installed if your OS requires that to enable a module.

 

Please select your OS:

 

 

 

CentOS | RHEL | Oracle Linux

Prerequisites

Perform these steps to install the pre-requisite packages.

===== CentOS | RHEL | Oracle Linux 5.x =====

yum install -y rrdtool perl-rrdtool php-gd
cpan -f -i Time::HiRes

 If CPAN has not been run before you will need to answer a series of questions, usually accepting the default choice using Enter will suffice.

 

===== CentOS | RHEL | Oracle Linux 6.x / 7.x =====

yum install -y rrdtool perl-rrdtool perl-Time-HiRes php-gd

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.tar.gz https://github.com/lingej/pnp4nagios/archive/0.6.26.tar.gz
tar xzf pnp4nagios.tar.gz

 

Compile & Install

cd pnp4nagios-0.6.26
./configure
make all
make install
make install-webconf
make install-config make install-init

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The Apache httpd service is also restarted at this point.

===== CentOS | RHEL | Oracle Linux 5.x / 6.x =====

chkconfig --add npcd
service npcd start
service httpd restart

 

===== CentOS | RHEL | Oracle Linux 7.x =====

systemctl daemon-reload
systemctl enable npcd.service
systemctl start npcd.service
systemctl restart httpd.service

 

Please proceed to the Nagios Command Configuration section for the next step.

 

 

Ubuntu

Prerequisites

Perform these steps to install the pre-requisite packages.

===== Ubuntu 14.x / 15.x =====

sudo apt-get update
sudo apt-get install -y rrdtool librrd-simple-perl php-gd

 

===== Ubuntu 16.x / 17.x =====

sudo apt-get update
sudo apt-get install -y rrdtool librrd-simple-perl php-gd php-xml

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.tar.gz https://github.com/lingej/pnp4nagios/archive/0.6.26.tar.gz
tar xzf pnp4nagios.tar.gz

 

Compile & Install

cd pnp4nagios-0.6.26
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
sudo make install
sudo make install-webconf
sudo make install-config
sudo make install-init

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The apache2 service is also restarted at this point.

===== Ubuntu 14.x =====

sudo update-rc.d npcd defaults
sudo service npcd start
sudo service apache2 restart

 

===== Ubuntu 15.x / 16.x / 17.x =====

sudo systemctl daemon-reload
sudo systemctl enable npcd.service
sudo systemctl start npcd.service
sudo systemctl restart apache2.service

 

Please proceed to the Nagios Command Configuration section for the next step.

 

 

SUSE SLES | openSUSE Leap

Prerequisites

Perform these steps to install the pre-requisite packages.

===== SUSE SLES 11.x =====

sudo zypper --non-interactive install rrdtool php-gd php-zlib php53-sockets

 

===== SUSE SLES 12.x | openSUSE =====

sudo zypper --non-interactive install rrdtool php5-gd php5-zlib php5-sockets

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.tar.gz https://github.com/lingej/pnp4nagios/archive/0.6.26.tar.gz
tar xzf pnp4nagios.tar.gz

 

Compile & Install

In the following commands an updated version of httpd.conf.in is downloaded so it works with the newer versions of Apache.

cd pnp4nagios-0.6.26
wget -O sample-config/httpd.conf.in https://raw.githubusercontent.com/lingej/pnp4nagios/master/sample-config/httpd.conf.in
sudo ./configure --with-httpd-conf=/etc/apache2/vhosts.d
sudo make all
sudo make install
sudo make install-webconf
sudo make install-config
sudo make install-init

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The apache2 service requires a module to be enabled and restarted at this point.

===== SUSE SLES 11.x =====

sudo /sbin/chkconfig --set npcd on
sudo /sbin/service npcd start
sudo /sbin/service apache2 restart

 

===== SUSE SLES 12.x | openSUSE =====

sudo systemctl daemon-reload
sudo systemctl enable npcd.service
sudo systemctl start npcd.service
sudo systemctl restart apache2.service

 

Please proceed to the Nagios Command Configuration section for the next step.

 

 

Debian | Raspbian

All steps on Debian require to run as root. To become root simply run:

Debian:

su

 

Raspbian:

sudo -i

 

All commands from this point onwards will be as root.

 

Prerequisites

Perform these steps to install the pre-requisite packages.

===== 7.x / 8.x =====

apt-get update
apt-get install -y rrdtool librrds-perl php5-gd

 

===== 9.x =====

apt-get update
apt-get install -y rrdtool librrds-perl php-gd php-xml

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.tar.gz https://github.com/lingej/pnp4nagios/archive/0.6.26.tar.gz
tar xzf pnp4nagios.tar.gz

 

Compile & Install

cd pnp4nagios-0.6.26
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
make install
make install-webconf
make install-config
make install-init

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The apache2 service is also restarted at this point.

===== 7.x =====

update-rc.d npcd defaults
service npcd start
service apache2 restart

 

===== 8.x / 9.x =====

systemctl daemon-reload
systemctl enable npcd.service
systemctl start npcd.service
systemctl restart apache2.service

 

Please proceed to the Nagios Command Configuration section for the next step.

 

 

Fedora

Prerequisites

Perform these steps to install the pre-requisite packages.

dnf install -y rrdtool perl-rrdtool perl-Time-HiRes php-gd php-xml
dnf update -y

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.tar.gz https://github.com/lingej/pnp4nagios/archive/0.6.26.tar.gz
tar xzf pnp4nagios.tar.gz

 

Compile & Install

cd pnp4nagios-0.6.26
./configure
make all
make install
make install-webconf
make install-config make install-init

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The Apache httpd service is also restarted at this point.

systemctl daemon-reload
systemctl enable npcd.service
systemctl start npcd.service
systemctl restart httpd.service

 

Please proceed to the Nagios Command Configuration section for the next step.

 

 

Arch Linux

Prerequisites

Perform these steps to install the pre-requisite packages.

pacman --noconfirm -Syyu
pacman --noconfirm -S rrdtool php-gd

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.zip https://github.com/lingej/pnp4nagios/archive/master.zip
unzip pnp4nagios.zip

 

Compile & Install

cd pnp4nagios-master
./configure --with-httpd-conf=/etc/httpd/conf/extra
make all
make install
make install-webconf
make install-config
wget -O /usr/lib/systemd/system/npcd.service https://aur.archlinux.org/cgit/aur.git/plain/npcd.service?h=pnp4nagios
sed -i 's/^ExecStart.*/ExecStart=\/usr\/local\/pnp4nagios\/bin\/npcd -d -f \/usr\/local\/pnp4nagios\/etc\/npcd.cfg/g' /usr/lib/systemd/system/npcd.service
echo 'Include "conf/extra/pnp4nagios.conf"' >> /etc/httpd/conf/httpd.conf
sed -i 's/^#LoadModule rewrite_module/LoadModule rewrite_module/g' /etc/httpd/conf/httpd.conf
sed -i 's/^;extension=gd/extension=gd/g' /etc/php/php.ini
sed -i 's/^;extension=iconv/extension=iconv/g' /etc/php/php.ini
sed -i 's/^;extension=sockets/extension=sockets/g' /etc/php/php.ini

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The Apache httpd service is also restarted at this point.

systemctl daemon-reload
systemctl enable npcd.service
systemctl start npcd.service
systemctl restart httpd.service

 

Please proceed to the Nagios Command Configuration section for the next step.

 

 

Gentoo

Prerequisites

Perform these steps to install the pre-requisite packages.

emerge --sync
echo "net-analyzer/rrdtool perl graph" >> /etc/portage/package.use/rrdtool
echo ">=perl-core/Time-HiRes-1.972.600-r1 **" >> /etc/portage/package.accept_keywords
echo ">=dev-perl/RRD-Simple-1.440.0-r2 **" >> /etc/portage/package.accept_keywords
emerge --noreplace net-analyzer/rrdtool dev-perl/RRD-Simple perl-core/Time-HiRes media-libs/gd
sed -i '/dev-lang\/php/s/$/ gd sockets/' /etc/portage/package.use/php
emerge -av dev-lang/php

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.zip https://github.com/lingej/pnp4nagios/archive/master.zip
unzip pnp4nagios.zip

 

Compile & Install

cd pnp4nagios-master
wget -O sample-config/httpd.conf.in https://raw.githubusercontent.com/lingej/pnp4nagios/master/sample-config/httpd.conf.in
./configure --with-httpd-conf=/etc/apache2/vhosts.d
make all
make install
make install-webconf
make install-config
wget -O /etc/init.d/npcd https://gitweb.gentoo.org/repo/gentoo.git/plain/net-analyzer/pnp4nagios/files/npcd.initd
sed -i 's/^command=.*/command="\/usr\/local\/pnp4nagios\/bin\/npcd"/g' /etc/init.d/npcd
sed -i 's/^command_args=.*/command_args="-f \/usr\/local\/pnp4nagios\/etc\/npcd.cfg -d"/g' /etc/init.d/npcd
chmod +x /etc/init.d/npcd

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The Apache apache2 service is also restarted at this point.

rc-update add npcd default
rc-service npcd start
rc-service apache2 restart

 

Please proceed to the Nagios Command Configuration section for the next step.

 

 

FreeBSD

Prerequisites

Perform these steps to install the pre-requisite packages.

pkg install -y rrdtool p5-RRD-Simple p5-Time-HiRes php70-gd php70-zlib php70-sockets

 

Downloading the Source

cd /tmp
wget -O pnp4nagios.tar.gz https://github.com/lingej/pnp4nagios/archive/0.6.26.tar.gz
tar xzf pnp4nagios.tar.gz

 

Compile & Install

cd pnp4nagios-0.6.26
sed -i '' 's/g root/g wheel/g' scripts/Makefile.in
./configure --with-httpd-conf=/usr/local/etc/apache24/Includes
gmake all
gmake install
gmake install-webconf
gmake install-config gmake install-init

 

Configure & Start Service / Daemon

The npcd service needs to be configured to start on boot, it also needs to be started. The Apache apache24 service is also restarted at this point.

echo '/usr/local/etc/rc.d/npcd start' >> /etc/rc.local
service npcd start
sed -i '' 's/^#LoadModule rewrite_module/LoadModule rewrite_module/g' /usr/local/etc/apache24/httpd.conf
service apache24 restart

 

Please proceed to the Nagios Command Configuration section for the next step.
 

 

 

Nagios Command Configuration

Once PNP4Nagios is running as the npcd service, the next step is to configure Nagios Core to send the performance data to PNP4Nagios.

This guide is configuring Nagios Core and PNP4Nagios in Bulk Mode. This documentation will not explain in detail how it all works, basically a bunch of temporary files are created and the npcd service preocesses these files and turns them into RRD files. Full detailed information is in the official PNP4Nagios documentation:

https://docs.pnp4nagios.org/pnp-0.6/config#bulk_mode_with_npcd

The following configuration changes are required to the /usr/local/nagios/etc/nagios.cfg file:

process_performance_data=1

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-bulk-npcd

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-bulk-npcd

 

In a fresh installation of Nagios Core the directive process_performance_data is set to 0 and the other directives are commented out.

To make the required changes above you can manually edit the file, or the following commands will make those changes for you:

CentOS / RHEL / Oracle Linux / Debian / Raspbian / Fedora / Arch Linux / Gentoo

sed -i 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#host_perfdata_file=/host_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^host_perfdata_file=.*/host_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#host_perfdata_file_template=.*/host_perfdata_file_template=DATATYPE::HOSTPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tHOSTPERFDATA::$HOSTPERFDATA$\\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#host_perfdata_file_mode=/host_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#host_perfdata_file_processing_interval=.*/host_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#host_perfdata_file_processing_command=.*/host_perfdata_file_processing_command=process-host-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#service_perfdata_file=/service_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^service_perfdata_file=.*/service_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#service_perfdata_file_template=.*/service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tSERVICEDESC::$SERVICEDESC$\\tSERVICEPERFDATA::$SERVICEPERFDATA$\\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$\\tSERVICESTATE::$SERVICESTATE$\\tSERVICESTATETYPE::$SERVICESTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#service_perfdata_file_mode=/service_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#service_perfdata_file_processing_interval=.*/service_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#service_perfdata_file_processing_command=.*/service_perfdata_file_processing_command=process-service-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg

 

Ubuntu / SLES / openSUSE

sudo sh -c "sed -i 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/#host_perfdata_file=/host_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^host_perfdata_file=.*/host_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^#host_perfdata_file_template=.*/host_perfdata_file_template=DATATYPE::HOSTPERFDATA\\\\tTIMET::\$TIMET\$\\\\tHOSTNAME::\$HOSTNAME\$\\\\tHOSTPERFDATA::\$HOSTPERFDATA\$\\\\tHOSTCHECKCOMMAND::\$HOSTCHECKCOMMAND\$\\\\tHOSTSTATE::\$HOSTSTATE\$\\\\tHOSTSTATETYPE::\$HOSTSTATETYPE\$/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/#host_perfdata_file_mode=/host_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^#host_perfdata_file_processing_interval=.*/host_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^#host_perfdata_file_processing_command=.*/host_perfdata_file_processing_command=process-host-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/#service_perfdata_file=/service_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^service_perfdata_file=.*/service_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^#service_perfdata_file_template=.*/service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\\\\tTIMET::\$TIMET\$\\\\tHOSTNAME::\$HOSTNAME\$\\\\tSERVICEDESC::\$SERVICEDESC\$\\\\tSERVICEPERFDATA::\$SERVICEPERFDATA\$\\\\tSERVICECHECKCOMMAND::\$SERVICECHECKCOMMAND\$\\\\tHOSTSTATE::\$HOSTSTATE\$\\\\tHOSTSTATETYPE::\$HOSTSTATETYPE\$\\\\tSERVICESTATE::\$SERVICESTATE\$\\\\tSERVICESTATETYPE::\$SERVICESTATETYPE\$/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/#service_perfdata_file_mode=/service_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^#service_perfdata_file_processing_interval=.*/service_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg"
sudo sh -c "sed -i 's/^#service_perfdata_file_processing_command=.*/service_perfdata_file_processing_command=process-service-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg"

 

FreeBSD

sed -i '' 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/#host_perfdata_file=/host_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^host_perfdata_file=.*/host_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^#host_perfdata_file_template=.*/host_perfdata_file_template=DATATYPE::HOSTPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tHOSTPERFDATA::$HOSTPERFDATA$\\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/#host_perfdata_file_mode=/host_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^#host_perfdata_file_processing_interval=.*/host_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^#host_perfdata_file_processing_command=.*/host_perfdata_file_processing_command=process-host-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/#service_perfdata_file=/service_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^service_perfdata_file=.*/service_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^#service_perfdata_file_template=.*/service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tSERVICEDESC::$SERVICEDESC$\\tSERVICEPERFDATA::$SERVICEPERFDATA$\\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$\\tSERVICESTATE::$SERVICESTATE$\\tSERVICESTATETYPE::$SERVICESTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/#service_perfdata_file_mode=/service_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^#service_perfdata_file_processing_interval=.*/service_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
sed -i '' 's/^#service_perfdata_file_processing_command=.*/service_perfdata_file_processing_command=process-service-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg

 

 

Two nagios commands need to be defined, it is recommended to place these in the /usr/local/nagios/etc/objects/commands.cfg file:

define command {
    command_name    process-service-perfdata-file-bulk-npcd
    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-bulk-npcd
    command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
    }

 

To make the required changes above you can manually edit the file, or the following commands will add those commands for you:

CentOS / RHEL / Oracle Linux / Debian / Raspbian / Fedora / FreeBSD / Arch Linux / Gentoo

echo '' >> /usr/local/nagios/etc/objects/commands.cfg
echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg
echo '    command_name    process-host-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg
echo '    command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$' >> /usr/local/nagios/etc/objects/commands.cfg
echo '    }' >> /usr/local/nagios/etc/objects/commands.cfg
echo '' >> /usr/local/nagios/etc/objects/commands.cfg
echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg
echo '    command_name    process-service-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg
echo '    command_line    /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$' >> /usr/local/nagios/etc/objects/commands.cfg
echo '    }' >> /usr/local/nagios/etc/objects/commands.cfg
echo '' >> /usr/local/nagios/etc/objects/commands.cfg

 

Ubuntu / SLES / openSUSE

sudo sh -c "echo '' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '    command_name    process-host-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '    command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.\$TIMET\$' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '    }' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '    command_name    process-service-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '    command_line    /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.\$TIMET\$' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '    }' >> /usr/local/nagios/etc/objects/commands.cfg"
sudo sh -c "echo '' >> /usr/local/nagios/etc/objects/commands.cfg"

 

 Once those changes have been performed you will need to verify the Nagios Core configuration with the following command:

CentOS / RHEL / Oracle Linux / Debian / Raspbian / Fedora / FreeBSD / Arch Linux / Gentoo

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

Ubuntu / SLES / openSUSE

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

If the verification was successful then you can restart the nagios service:

CentOS / RHEL / Oracle Linux

===== 5.x / 6.x =====

service nagios restart

 

===== 7.x =====

systemctl restart nagios.service

 

Ubuntu

===== 14.x =====

sudo service nagios restart

 

===== 15.x / 16.x / 17.x =====

sudo systemctl restart nagios.service

 

SLES / openSUSE

===== SUSE SLES 11.x =====

sudo /sbin/service nagios restart

 

===== SUSE SLES 12.x | openSUSE =====

sudo systemctl restart nagios.service

 

Debian / Raspbian

===== 7.x =====

service nagios restart

 

===== 8.x / 9.x =====

systemctl restart nagios.service

 

Fedora / Arch Linux

systemctl restart nagios.service

 

FreeBSD

service nagios restart

 

Gentoo

rc-service nagios restart

 

 The next step is to verify that PNP4Nagios is working.

 

 

 

Verify PNP4Nagios Is Working

The first step in verifying that PNP4Nagios is working is to look at the RRD files that should now exist. By following this guide they should exist in /usr/local/pnp4nagios/var/perfdata/. There will be a folder for each Nagios host, here you can see the localhost and it's services by executing this command:

ls -la /usr/local/pnp4nagios/var/perfdata/localhost/

 

The output from that command should resemble (it might take up to 5 minutes for files to appear here):

total 5308
drwxrwxr-x. 2 nagios nagios    4096 Feb 27 16:18 .
drwxr-xr-x. 4 nagios nagios    4096 Feb 27 14:41 ..
-rw-rw-r--. 1 nagios nagios 1151280 Feb 27 16:17 Current_Load.rrd
-rw-rw-r--. 1 nagios nagios    3428 Feb 27 16:17 Current_Load.xml
-rw-rw-r--. 1 nagios nagios  384736 Feb 27 16:18 Current_Users.rrd
-rw-rw-r--. 1 nagios nagios    1976 Feb 27 16:18 Current_Users.xml
-rw-rw-r--. 1 nagios nagios  768008 Feb 27 16:18 _HOST_.rrd
-rw-rw-r--. 1 nagios nagios    2555 Feb 27 16:18 _HOST_.xml
-rw-rw-r--. 1 nagios nagios  768008 Feb 27 16:18 HTTP.rrd
-rw-rw-r--. 1 nagios nagios    2565 Feb 27 16:18 HTTP.xml
-rw-rw-r--. 1 nagios nagios  768008 Feb 27 16:14 PING.rrd
-rw-rw-r--. 1 nagios nagios    2655 Feb 27 16:14 PING.xml
-rw-rw-r--. 1 nagios nagios  384736 Feb 27 16:15 Root_Partition.rrd
-rw-rw-r--. 1 nagios nagios    2021 Feb 27 16:15 Root_Partition.xml
-rw-rw-r--. 1 nagios nagios  384736 Feb 27 16:15 SSH.rrd
-rw-rw-r--. 1 nagios nagios    1938 Feb 27 16:15 SSH.xml
-rw-rw-r--. 1 nagios nagios  384736 Feb 27 16:16 Swap_Usage.rrd
-rw-rw-r--. 1 nagios nagios    1974 Feb 27 16:16 Swap_Usage.xml
-rw-rw-r--. 1 nagios nagios  384736 Feb 27 16:17 Total_Processes.rrd
-rw-rw-r--. 1 nagios nagios    2015 Feb 27 16:17 Total_Processes.xml

 

There is also a web interface for PNP4Nagios. Open your web browser to the following URL:

http://nagios_server/pnp4nagios/

Replace nagios_server with the DNS record or ip address of your Nagios Core server.

This will display a page of test results, they should all be passed, most importantly is this statement at the bottom of the page:

Your environment passed all requirements. Remove or rename the /usr/local/pnp4nagios/share/install.php file now.

To remove the install.php file execute the following command:

CentOS / RHEL / Oracle Linux / Debian / Raspbian / Fedora / FreeBSD / Arch Linux / Gentoo

rm -f /usr/local/pnp4nagios/share/install.php

 

Ubuntu / SLES / openSUSE

sudo rm -f /usr/local/pnp4nagios/share/install.php

 

After executing the command you need to refresh your web browser and you will start to see the Nagios graphs. For example:

 

 

 

If you are seeing the graphs then everything appears to be functioning correctly. Your next step is to configure Nagios Core Web Interface Integration.

 

 

 

Nagios Core Web Interface Integration

PNP4Nagios can also be integrated into the Nagios Core web interface, this is quite useful however it does require some changes to your Nagios object definitions.

Nagios Core uses the action_url directive in object definitions to provide an icon/link when viewing host or service objects in the web interface.

This means that every object in Nagios Core requires the action_url directive to be defined. This can be easily achieved by using a template and using that template in your object definitions.

In a fresh installation of Nagios Core the following host and service templates need to be added to /usr/local/nagios/etc/objects/templates.cfg file:

define host {
   name       host-pnp
   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
   register   0
}

define service {
   name       service-pnp
   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
   register   0
}

 

To make the required changes above you can manually edit the file, or the following commands will add those templates for you:

CentOS / RHEL / Oracle Linux / Debian / Raspbian / Fedora / FreeBSD / Arch Linux / Gentoo

echo '' >> /usr/local/nagios/etc/objects/templates.cfg
echo 'define host {' >> /usr/local/nagios/etc/objects/templates.cfg
echo '  name       host-pnp' >> /usr/local/nagios/etc/objects/templates.cfg
echo '   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' >> /usr/local/nagios/etc/objects/templates.cfg
echo '  register   0' >> /usr/local/nagios/etc/objects/templates.cfg
echo '}' >> /usr/local/nagios/etc/objects/templates.cfg
echo '' >> /usr/local/nagios/etc/objects/templates.cfg
echo 'define service {' >> /usr/local/nagios/etc/objects/templates.cfg
echo '   name       service-pnp' >> /usr/local/nagios/etc/objects/templates.cfg
echo '   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' >> /usr/local/nagios/etc/objects/templates.cfg
echo '   register   0' >> /usr/local/nagios/etc/objects/templates.cfg
echo '}' >> /usr/local/nagios/etc/objects/templates.cfg
echo '' >> /usr/local/nagios/etc/objects/templates.cfg

 

Ubuntu / SLES / openSUSE

sudo sh -c "echo '' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo 'define host {' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '   name       host-pnp' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '   action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME\$&srv=_HOST_' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '   register   0' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '}' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo 'define service {' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '   name       service-pnp' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '   action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME\$&srv=\$SERVICEDESC\$' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '   register   0' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '}' >> /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "echo '' >> /usr/local/nagios/etc/objects/templates.cfg"

 

Then to use those templates you need to include them in your host and service directives. This example will update the generic-host and generic-service templates to include these templates, here is how they should look:

define host{
        name                            generic-host    ; The name of this host template
        use                             host-pnp

define service{
        name                            generic-service         ; The 'name' of this service template
        use                            service-pnp

 In the example above the remaining options in the default templates have been omitted, there is no point showing all of those entries.

 

To make the required changes above you can manually edit the file, or the following commands will update those templates for you:

CentOS / RHEL / Oracle Linux / Debian / Raspbian / Fedora / Arch Linux / Gentoo

sed -i '/name.*generic-host/a\        use                             host-pnp' /usr/local/nagios/etc/objects/templates.cfg
sed -i '/name.*generic-service/a\        use                             service-pnp' /usr/local/nagios/etc/objects/templates.cfg

 

Ubuntu / SLES / openSUSE

sudo sh -c "sed -i '/name.*generic-host/a\        use                             host-pnp' /usr/local/nagios/etc/objects/templates.cfg"
sudo sh -c "sed -i '/name.*generic-service/a\        use                             service-pnp' /usr/local/nagios/etc/objects/templates.cfg"

 

FreeBSD

perl -ni.bak -le 'print; print "        use                             host-pnp" if /name.*generic-host/' /usr/local/nagios/etc/objects/templates.cfg
perl -ni.bak -le 'print; print "        use                             service-pnp" if /name.*generic-service/' /usr/local/nagios/etc/objects/templates.cfg

 

Once those changes have been performed you will need to verify the Nagios Core configuration with the following command:

CentOS / RHEL / Oracle Linux / Debian / Raspbian / Fedora / FreeBSD / Arch Linux / Gentoo

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

Ubuntu / SLES / openSUSE

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

If the verification was successful then you can restart the nagios service:

CentOS / RHEL / Oracle Linux

===== 5.x / 6.x =====

service nagios restart

 

===== 7.x =====

systemctl restart nagios.service

 

Ubuntu

===== 14.x =====

sudo service nagios restart

 

===== 15.x / 16.x / 17.x =====

sudo systemctl restart nagios.service

 

SLES / openSUSE

===== SUSE SLES 11.x =====

sudo /sbin/service nagios restart

 

===== SUSE SLES 12.x | openSUSE =====

sudo systemctl restart nagios.service

 

Debian / Raspbian

===== 7.x =====

service nagios restart

 

===== 8.x / 9.x =====

systemctl restart nagios.service

 

Fedora / Arch Linux

systemctl restart nagios.service

 

FreeBSD

service nagios restart

 

Gentoo

rc-service nagios restart

 

Finally open the Nagios Core web interface and navigate to the Services page, you should now see a graph icon for all the hosts and services. Clicking on an icon will open the host or service graph for that object in the PNP4Nagios web interface.

 

 

This completes the steps required for integrating PNP4Nagios with Nagios Core.

 

 

Additional Reading

This documentation would not have been possible without the official documentation available here:

https://docs.pnp4nagios.org/

 

 

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/

5 (1)
Article Rating (1 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
Nagios Core - Performance Graphs Using InfluxDB + Nagflux + Grafana + Histou
Viewed 11557 times since Sun, Mar 4, 2018
Nagios Core 4 - Status Maps
Viewed 2283 times since Wed, Jul 19, 2017
Nagios Core - Graphing Performance Info With MRTG
Viewed 4215 times since Mon, Feb 1, 2016
Nagios Core - Performance Data
Viewed 3580 times since Mon, Feb 1, 2016
Nagios Core - Custom CGI Headers and Footers
Viewed 3039 times since Mon, Feb 1, 2016
Nagios Core - Using Grafana With PNP4Nagios
Viewed 5598 times since Wed, Mar 7, 2018
Nagios Core - Status Map Customization (Legacy)
Viewed 9070 times since Sun, Jul 23, 2017
Nagios Core - Status Map Customization
Viewed 4747 times since Tue, Jul 25, 2017