PNP4Nagios Documentation Version 0.6.17

Nagios web frontend

Of course PNP should be easily accessible. You do not want to search long for the right graph.

Nagios itself features external URLs using so called extended info configs. Due to changes between Nagios 2.x and Nagios 3.x both versions are described.

Nagios 2.x

With Nagios 2.x the integration of external URLs into the nagios web interface is made using Extended Info Objects for services. For PNP we use the directive action_url to call the PNP web frontend with the appropriate options.

define serviceextinfo {
   host_name             localhost
   service_description   load
   action_url            /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
}

You have to specify an additional Extended Info Definition for every service.

Nagios 3.x

Since nagios 3.0 the action_url-directive has be moved to the host or service definition. This way the definition of URLs to the PNP-interface has been simplified. The serviceextinfo and hostextinfo definitions are deprecated.

First two nagios templates are defined. If you used the Nagios quickstart installation guides you can append these lines to 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
}

These two templates can now be included via “use srv-pnp” or “use host-pnp” for services and hosts respectively. If you used the quickstart installation guide you might for example edit the file localhost.cfg and add the template to the host or service definition as follows:

define host{
  use                     linux-server,host-pnp    ; Name of host templates to use
                                                   ; inherit all variables that are defined
                                                   ; or inherited by the template definition
  host_name               localhost
  alias                   localhost
  address                 127.0.0.1
  }
define service{
  use                     local-service,srv-pnp   ; Name of service template to use
  host_name               localhost
  service_description     PING
  check_command           check_ping!100.0,20%!500.0,60%
  }

The links to the correct URLs are created automagically.

Tips: if you want to open the PNP window in your main frame (on the right of the menu) instead of a new page, just set action_url_target=main in your nagios cgi.cfg

Popups

You can integrate PNP into Nagios in a way that you have current graphs without clicking any icons. This can be accomplished using the CGI Includes which allow us to include JavaScript code in the status detail view ( status.cgi ).

Prerequisites:

  • PNP is installed and running
  • the file status-header.ssi from the contrib/ssi/ folder of the PNP package was copied to /usr/local/nagios/share/ssi/.
    Attention: This file must NOT be executable. Otherwise it will be treated as a CGI which will result in an error.
    *Note to Apache admins*: Apache ssi and Nagios ssi only have a similar name.
  • the appropriate service definition(s) has/have been modified. Please note that until Nagios 2.x you have to modify the serviceextinfo definition (which is deprecated starting with Nagios 3).

Definition:

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
}

After a restart of Nagios (after modifying the definitions) the result might look like this:

back to contents | config options