Table of Contents
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 /nagios/pnp/index.php?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. The serviceextinfo and hostextinfo definitions are deprecated. This way the definition of URLs to the PNP-interface has been simplified.
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 register 0 action_url /nagios/pnp/index.php?host=$HOSTNAME$ } define service { name srv-pnp register 0 action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$ }
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 ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host 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.
Popups
Starting with PNP 0.4.13 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 directory
/usr/local/nagios/share/pnp/include/js
contains the filesprototype.js
undoverlib_mini.js
. Depending on the distribution the share folder may be located elsewhere. If in doubt have a look at the alias definition in the Nagios configuration file of your web server. - the directory
ssi
from the contrib folder of the PNP package was copied to /usr/local/nagios/share. Please review the paths in the file status-header.ssi (both js-files and the ajax.php).
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 register 0 action_url /nagios/pnp/index.php?host=$HOSTNAME$' onmouseover="get_g('$HOSTNAME$','_HOST_')" onmouseout='clear_g() } define service { name srv-pnp register 0 action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$' onmouseover="get_g('$HOSTNAME$','$SERVICEDESC$')" onmouseout='clear_g() }
After a restart of Nagios (after modifying the definitions) the result might look like this: