Pnp4nagios Pi – Integrate With Nagios Web Interface

Pnp4nagios Pi – Integrate With Nagios Web Interface

Define pnp4nagios host and service definitions

Pnp4nagios can be integrated in to Nagios using the action_url directive in host and service definitions to add an icon / link to graphs.

The first step to integrate pnp4nagios with the Nagios web interface is to define host and service definitions by performing the following steps:

  • Logon to the Raspberry Pi and execute the following command to become root:
sudo -i
  • Backup the existing  /usr/local/nagios/etc/objects/template.cfg file (Optional step)
cp /usr/local/nagios/etc/objects/templates.cfg /usr/local/nagios/etc/objects/templates.cfg-beforepnp4nagios
  • Next edit /usr/local/nagios/etc/objects/templates.cfg using the editor of your choice
  • Go to the end of the file and add the host and services definitions below:
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

Update the Nagios generic definitions

  • Next locate the generic-host definition and add in the line shown below in bold:
define host{
        name            generic-host ; The name of this host template
        use             host-pnp
  • FInally locate the generic-service definition and add in the line shown below in bold:
define service{
    name                generic-service ; The 'name' of this service template
    use                 service-pnp
  • Save and exit the file
  • Following the modifications to the templates.cfg file Nagios needs to be restarted by executing the following command:
systemctl restart nagios

PHP 7 Modification

Following the installation and configuration of pnp4nagios I encountered the error shown in the screen shot below:

A quick google turned up the following article which gave the solution below for me as my Pi is running PHP 7:

  • Edit the /usr/local/pnp4nagios/share/application/models/data.php file
  • Go to line 979 and change if(sizeof($pages) > 0 ){ to if(is_arrary($pages) && sizeof($pages) > 0 ){
  • Save and exit the file

Leave a Reply

Your email address will not be published.