How to Install PNP4nagios from EPEL on RHEL 6

Install EPEL repository

rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Install the required packages

yum install httpd nagios nagios-plugins-all pnp4nagios

Configure PNP4nagios

From file /etc/pnp4nagios/nagios.cfg copy the following lines to /etc/nagios/nagios.cfg.

Just change broker_module line to actual broker module path.

vi /etc/nagios/nagios.cfg

#
# Bulk / NPCD mode
# 

process_performance_data=1

# *** the template definition differs from the one in the original nagios.cfg
#
service_perfdata_file=/var/log/pnp4nagios/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=/var/log/pnp4nagios/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

#
# Module mode
# 
event_broker_options=-1 # minimum 4+8=12
process_performance_data=1
broker_module=/usr/lib64/nagios/brokers/npcdmod.o config_file=/etc/pnp4nagios/npcd.cfg

From file /etc/pnp4nagios/misccommands.cfg copy the following lines to /etc/nagios/objects/commands.cfg

vi /etc/nagios/objects/commands.cfg

#
# Bulk with NPCD mode
#
define command {
       command_name    process-service-perfdata-file
       command_line    /bin/mv /var/log/pnp4nagios/service-perfdata /var/spool/pnp4nagios/service-perfdata.$TIMET$
}

define command {
       command_name    process-host-perfdata-file
       command_line    /bin/mv /var/log/pnp4nagios/host-perfdata /var/spool/pnp4nagios/host-perfdata.$TIMET$
}

vi /etc/nagios/objects/templates.cfg

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

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

Add the template for every host and service

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

Check the configuration

cd /tmp

wget http://verify.pnp4nagios.org/verify_pnp_config

perl verify_pnp_config --mode bulk+npcd --config=/etc/nagios/nagios.cfg --pnpcfg=/etc/pnp4nagios

Restart nagios and start npcd service

/etc/init.d/nagios restart

chkconfig npcd on

/etc/init.d/npcd start

Troubleshooting

less /var/log/pnp4nagios/perfdata.log

grep npcdmod /var/log/nagios/nagios.log

Resources