PNP4Nagios
From openSUSE
| PNP is an addon to Nagios which analyzes performance data provided by plugins and stores them automatically into RRD-databases (Round Robin Databases, see RRD Tool). |
|
| |||||||||||||||||||||||||
Configuration of PNP for Nagios
Configuring Apache2
The pnp graphs can be viewed with a webinterface. For this, you need apache2 to be started during boot:
insserv apache2
Per default, only connects from localhost are allowed. Adjust the configfile /etc/apache2/conf.d/nagios-pnp.conf for your needs. And define the apache server flag PNP4NAGIOS in /etc/sysconfig/apache2 in the following line:
APACHE_SERVER_FLAGS="PNP4NAGIOS"
If not already done for nagios, create a password file for apache and add an apache user named 'nagiosadmin' (or any other username you like):
touch /etc/nagios/htpasswd.users chown root:www /etc/nagios/htpasswd.users chmod 640 /etc/nagios/htpasswd.users htpasswd2 -s /etc/nagios/htpasswd.users nagiosadmin
You can also use an alternative htpasswd file to allow only a limited amount of people to view the pnp graphs.
Therefore you should point the 'AuthUserFile' value in /etc/apache2/conf.d/nagios-pnp.conf to the location of your htpasswd file.
Now it's time to start the webserver with the following command:
rcapache2 start
or - if your webserver is already running:
rcapache2 restart
Configuring Nagios
Your next step should now be to enable performance data in your /etc/nagios/nagios.cfg with following option:
process_performance_data=1
and:
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
after editing your nagios.cfg (don't forgett to add the sections below) set the service option:
process_perf_data 1
for each service that supports 'real' performance data and finaly which you wants to see within PNP.
| With Nagios 3.x you can put "process_perf_data 1" in your service definition or template! |
Running in Simple (Default) mode
| Note: the pnp4nagios package installs the config below automatically in /etc/nagios/nagios-pnp.cfg |
In your commands.cfg you have to add a commands like this:
# Default mode
define command {
command_name process-service-perfdata
command_line $USER1$/process_perfdata.pl
}
define command {
command_name process-host-perfdata
command_line $USER1$/process_perfdata.pl -d HOSTPERFDATA
}
# Bulk mode
define command {
command_name perfdata-service-pnp-bulk
command_line $USER1$/process_perfdata.pl --bulk=/var/spool/nagios-pnp/service-perfdata
}
define command {
command_name perfdata-host-pnp-bulk
command_line $USER1$/process_perfdata.pl --bulk=/var/spool/nagios-pnp/host-perfdata
}
Running in Faster (Bulk) mode
Nagios writes perfdata into files (/var/spool/nagios-pnp/service-perfdata and host-perfdata). Every 15 seconds it executes PNP's process_perfdata.pl via perfdata-service-pnp-bulk and perfdata-host-pnp-bulk. Let's start a little bit of copy&paste to nagios.cfg here:
# # Host Performancedata (Nagios 3.x) # service_perfdata_file=/var/spool/nagios-pnp/host-perfdata host_perfdata_file=/var/spool/nagios-pnp/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=perfdata-host-pnp-bulk # # Service Performancedata # service_perfdata_file=/var/spool/nagios-pnp/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=perfdata-service-pnp-bulk
Including links in Nagios' Webfrontend
For integrating the URLs you could create "hostextinfo" or "serviceextinfo" objects:
# For all hosts go to the overview page
define hostextinfo {
host_name *
action_url /pnp/index.php?host=$HOSTNAME$
}
or
# For one service
define serviceextinfo {
host_name localhost
service_description Ping
action_url /pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
| With Nagios 3.x you can put "action_url" in your service definition or template! |
Enabling the Nagios-Perfdata-C-Daemon
Don't forget to enable the Nagios-Perfdata-C-Daemon with
insserv npcd rcnpcd start
at the end...

