6.8. Integration of PNP4Nagios into Icinga-Web
Prev | Chapter 6. User Interfaces | Next

## 6.8. Integration of PNP4Nagios into Icinga-Web

Here we'll give you some instructions on how to integrate PNP4Nagios into the Icinga-Web frontend. If you want to integrate PNP4Nagios into the Icinga Classic UI please follow the PNP4Nagios documentation.

Figure 6.35. PNP4Nagios integrated in Icinga-Web

### 6.8.1. Install PNP4Nagios

1. Install PNP4Nagios as described in the PNP4Nagios documentation

2. Change the PNP4Nagios configuration to match your Icinga configuration. You probably may want to change these:

       #> vi npcd.cfg

           user = icinga
           group = icinga
           log_file = /var/log/icinga/npcd.log
           perfdata_spool_dir = /var/icinga/spool/
           perfdata_file = /var/icinga/perfdata.dump

       #> vi process_perfdata.cfg

           LOG_FILE = /var/log/icinga/perfdata.log
           XML_ENC = ISO-8859-1  # use if encountering national character issues

       #> vi config.php
           $conf['nagios_base'] = "/icinga/cgi-bin";

   | Note
   Be sure to use existing paths, create them if necessary, and/or adapt the settings to your distribution. Please verify that the Icinga command definitions for "process-host-perfdata-file" and "process-service-perfdata-file" (probably in `etc/objects/commands.cfg`) point to the same target directory as specified in perfdata_spool_dir.

### 6.8.2. Templates Extension

Since version 1.5 you can leave the grid templates untouched because we integrated XML extension to customize grid templates with simple snippets. PNP integration is made with these extensions to be upgrade safe.

Excerpt from the `INSTALL` in `contrib/PNP_Integration/`

    #> cat contrib/PNP_Integration/INSTALL
        ************************
        * INSTALLATION
        ************************

        * To install this addon, simply copy both xml files under templateExtensions
        * to your icinga-webs app/modules/Cronks/data/xml/extensions folder
        * and clear the app/cache/CronkTemplates folder
        * To remove it, just delete the extension files and clear the cache folder again

Install Script

     $> cd etc/contrib/PNP_Integration
     $> sh install.sh

| Note
Please note that you will have to reinstall the addon after Icinga-Web upgrade.

### 6.8.3. Create a configuration to include PNP4Nagios host pages in Icinga-Web

| Note
The following lines describing the manual integration are for version 1.4 and below

1. Create a new grid view

   Make a copy of the default icinga-host-template.xml in app/modules/Cronks/data/xml/grid under your Icinga-Web installation path, example:

       #> cp /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/icinga-host-template.xml \
           /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/icinga-my-host-template.xml

   In the new file we just created add a new field definition:

               <field name="pnp4nagios_host_link">
                   <!-- datasource maps a data field from api call -->
                   <datasource>
                       <parameter name="field">HOST_NAME</parameter>
                   </datasource>

                   <display>
                       <parameter name="visible">true</parameter>
                       <parameter name="label">Perfdata</parameter>
                       <parameter name="width">55</parameter>

                       <parameter name="Ext.grid.Column">
                           <parameter name="menuDisabled">true</parameter>
                           <parameter name="fixed">true</parameter>
                       </parameter>

                       <parameter name="jsFunc">
                           <!-- function to display column with icon in host status grid view -->
                           <parameter>
                               <parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
                               <parameter name="function">columnImage</parameter>
                               <parameter name="type">renderer</parameter>

                               <parameter name="arguments">
                                   <parameter name="image">images/icons/application_view_gallery.png</parameter>
                                   <parameter name="css">x-icinga-grid-link</parameter>
                                   <parameter name="attr">
                                       <parameter name="qtip">Show host perfdata for this host</parameter>
                                   </parameter>
                               </parameter>
                           </parameter>

                           <!-- create cell click event for the previously defined column -->
                           <parameter>
                               <parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
                               <parameter name="function">iFrameCronk</parameter>
                               <parameter name="type">cellclick</parameter>
                               <parameter name="arguments">
                                   <parameter name="title">Host perfdata for {host_name}</parameter>
                                   <parameter name="url"><![CDATA[/pnp4nagios/index.php/graph?host={host_name}&srv=_HOST_]]></parameter>
                                   <parameter name="activateOnClick">true</parameter>
                               </parameter>
                           </parameter>
                       </parameter>
                   </display>

                   <filter>
                      <parameter name="enabled">false</parameter>
                   </filter>

                   <order>
                       <parameter name="enabled">false</parameter>
                   </order>
               </field>

2. Add the new grid view to the "Data" cronk-container

   Edit cronks.xml in directory app/modules/Cronks/config/ under your icinga-web add a section:

       <cronk name="gridMyHostView">
           <ae:parameter name="module">Cronks</ae:parameter>
           <ae:parameter name="action">System.ViewProc</ae:parameter>
           <ae:parameter name="hide">false</ae:parameter>
           <ae:parameter name="description">Viewing Host status in a grid including perfdata link</ae:parameter>
           <ae:parameter name="name">MyHostStatus</ae:parameter>
           <ae:parameter name="image">cronks.Stats</ae:parameter>
           <ae:parameter name="categories">data</ae:parameter>
           <ae:parameter name="ae:parameter">
               <ae:parameter name="template">icinga-my-host-template</ae:parameter>
           </ae:parameter>
       </cronk>

### 6.8.4. Create a configuration to include pnp4nagios service pages in icinga-web

| Note
The following lines describing the manual integration are for version 1.4 and below

1. Create a new grid view

   Make a copy of the default icinga-service-template.xml in app/modules/Cronks/data/xml/grid under your icinga-web installation path.

       cp /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/icinga-service-template.xml \
           /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/icinga-my-service-template.xml

   In the new file we just created add a new field definition:

               <field name="pnp4nagios_service_link">
                   <!-- datasource maps a data field from api call -->
                   <datasource>
                       <parameter name="field">SERVICE_NAME</parameter>
                   </datasource>

                   <display>
                       <parameter name="visible">true</parameter>
                       <parameter name="label">Perfdata</parameter>
                       <parameter name="width">55</parameter>

                       <parameter name="Ext.grid.Column">
                           <parameter name="menuDisabled">true</parameter>
                           <parameter name="fixed">true</parameter>
                       </parameter>

                       <parameter name="jsFunc">
                           <!-- function to display column with icon in host status grid view -->
                           <parameter>
                               <parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
                               <parameter name="function">columnImage</parameter>
                               <parameter name="type">renderer</parameter>

                               <parameter name="arguments">
                                   <parameter name="image">images/icons/application_view_gallery.png</parameter>
                                   <parameter name="css">x-icinga-grid-link</parameter>
                                   <parameter name="attr">
                                       <parameter name="qtip">Show perfdata for this service</parameter>
                                   </parameter>
                               </parameter>
                           </parameter>

                           <!-- create cell click event for the previously defined column -->
                           <parameter>
                               <parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
                               <parameter name="function">iFrameCronk</parameter>
                               <parameter name="type">cellclick</parameter>
                               <parameter name="arguments">
                                   <parameter name="title">Service perfdata for {service_name} on {host_name}</parameter>
                                   <parameter name="url"><![CDATA[/pnp4nagios/index.php/graph?host={host_name}&srv={service_name}]]></parameter>
                                   <parameter name="activateOnClick">true</parameter>
                               </parameter>
                           </parameter>
                       </parameter>
                   </display>

                   <filter>
                       <parameter name="enabled">false</parameter>
                   </filter>

                   <order>
                       <parameter name="enabled">false</parameter>
                   </order>
               </field>

2. Add the new grid view to the "Data" Cronk-Container

   Edit cronks.xml in directory app/modules/Cronks/config/ under your icinga-web add a section:

       <cronk name="gridMyServiceView">
           <ae:parameter name="module">Cronks</ae:parameter>
           <ae:parameter name="action">System.ViewProc</ae:parameter>
           <ae:parameter name="hide">false</ae:parameter>
           <ae:parameter name="description">Viewing service status in a grid including perfdata link</ae:parameter>
           <ae:parameter name="name">MyServiceStatus</ae:parameter>
           <ae:parameter name="image">cronks.Stats2</ae:parameter>
           <ae:parameter name="categories">data</ae:parameter>
           <ae:parameter name="ae:parameter">
               <ae:parameter name="template">icinga-my-service-template</ae:parameter>
           </ae:parameter>
       </cronk>

3. Using your new created grid view as default (if you want)

   Please backup your original view first:

       #> cp data/xml/grid/icinga-service-template.xml data/xml/grid/icinga-service-template.bak

   then

       #> cp data/xml/grid/icinga-my-service-template.xml data/xml/grid/icinga-service-template.xml

   Clear the cache, like described below. Performance graphs are now in your default "serviceStatus" Cronk!

### 6.8.5. Clearing the cache

| Note
If you edit any *.xml file you have to clear the cache afterwards!

    #> rm -f app/cache/config/*.php

or /path/to/clearcache.sh

    #> /usr/local/icinga-web/bin/clearcache.sh

That's all, you're done!

Prev | Up | Next
6.7. Introduction to Icinga-Web | Home | Chapter 7. Advanced Topics

© 2009-2013 Icinga Development Team, http://www.icinga.org