PNP4Nagios : Grapher ses alertes Nagios

From Deimos.fr / Bloc Notes Informatique
Jump to: navigation, search
PNP4Nagios

1 Introduction

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).

2 Prerequisites

First, create a folder where to unzip the installation files. Here, we are going to use /etc/nagios3/pnp4nagios :

Command
mkdir /etc/nagios3/pnp4nagios
cd /etc/nagios3/pnp4nagios

Then get the file, unzip and go into the folder :

Command
wget http://downloads.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.0.tar.gz?use_mirror=freefr
cd pnp4nagios-0.6.0

Activate the Apache2 rewrite module :

Command
a2enmod rewrite
/etc/init.d/apache2 restart

Edit the php5 conf file in /etc/php5 on this line :

Configuration File /etc/php5
magic_quotes_gpc = Off

If not installed yet, install GCC (C compiler)

Command aptitude
aptitude install gcc

3 Installation

Configure the installation, using the folder you want to install pnp4nagios in :

Command configure
./configure --prefix=/etc/nagios3/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios

Launch every make command :

Command make
make all
make install
make install-webconf
make install-config
make install-init

4 Configuration

In the nagios generic services file add :

Configuration File /etc/nagios3/conf.d/generic-services.cfg
...
define command {
       command_name    process-service-perfdata
       command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
}

And in the generic hosts file add :

Configuration File /etc/nagios3/conf.d/generic-host.cfg
define command {
       command_name    process-host-perfdata
       command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}

Edit the nagios.cfg file and be sure those line are uncommented :

Configuration File /etc/nagios3/nagios.cfg
process_performance_data=1
service_perfdata_command=process-service-perfdata
host_perfdata_command=process-host-perfdata

In any service or host configuration file, add (use generic-*.cfg for example) :

Configuration File /etc/nagios3/conf.d/generic-*.conf
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
}

Now for any host and service you want to use pnp4nagios with, on its "use" line, add this for a host :

host-pnp

and for a service :

srv-pnp

Example :

Configuration File
...
define service{
        use                     generic-services,srv-pnp

You can add it on a generic host or service used by a group of hosts or services. This will be inherited.

4.1 Onmouseover graphs in cgi interface

Copy the ssi files in the pnp4nagios contrib folder (pnp4nagios-0.6.0/contrib/ssi/*) in the nagios ssi folder (/usr/share/nagios3/htdocs/ssi/) :

Command
cp -Rf /etc/nagios3/pnp4nagios/pnp4nagios-0.6.0/contrib/ssi/*.ssi /usr/share/nagios3/htdocs/ssi/
rm -Rf /etc/nagios3/pnp4nagios/pnp4nagios-0.6.0/

Finally, restart apache2 and nagios and everything will work fine. You can see the PNP4Nagios interface to : http://nagios-srv/pnp4nagios