Pnp4Nagios installation and configuration on nagios4


PNP4Nagios


// we assume you have already install nagios core 

Part 1.  installation of pnp4nagios

We start with the simplest. We download the latest available version of pnp4nagios, in our case 0.6.24, unpack, compile and activate the service.


Prerequisite software required

    - rrdtool
    - librrds-perl
    - g++
    - php5-cli
    - php5-gd
    - libapache2-mod-php5


tar zxvf pnp4nagios-0.6.24.tar.gz
cd pnp4nagios-0.6.24
./configure
make all
make fullinstall

To check pnp4nagios  http://localhost/pnp4nagios/

We must remove the following file if we have the pnp4nagios:
rm -rf /usr/local/pnp4nagios/share/install.php

Part 2.  Edit nagios.cfg

This is the most complicated part, we need to edit the file and add the following lines indicated.
We begin with the main configuration file for Nagios, where besides adding the lines  look for the "process_performance_data" parameter and will equal 1.

vi /usr/local/nagios/etc/nagios.cfg

process_performance_data=1
#
# Bulk / NPCD mode
#
# *** the template definition differs from the one in the original nagios.cfg
#
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
# *** the template definition differs from the one in the original nagios.cfg
#
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


Part 3 :  add the necessary commands.

vi /usr/local/nagios/etc/objects/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$
}

Part 4 : create a  templates(host-pnp and srv-pnp)

And finally we will create a few templates (you can put the name you please). These templates we simply activate the "action_url" so that we have a direct link to pnp4nagios.

vi /usr/local/nagios/etc/objects/templates.cfg

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
}




You can also put host and service object in default template to apply on all host client which is associated to default host and default services else use as below 


Part 5 : use template

Modify required host and service objects to use inheritance with pnp4nagios specific templates created previously (use property):
define host{
use linux-server,host-pnp
host_name localhost
alias localhost
address 127.0.0.1
}
define service{
use local-service,srv-pnp
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}

Finally we restart services.
service npcd restart && service nagios restart

Part 6.

Finally we will give some added value. Copying this small file to the specified folder hovering over the icon of "action_url" We can see a thumbnail of the graph. Simple but gives a "touch".

cp contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/ //on pnp4nagios directory

pnp4nagios

Comments

Popular posts from this blog

Kubernetes with UI installation on Ubuntu 14.04