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

## 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.50. PNP4Nagios integrated in Icinga-Web

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

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

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

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:

       <ae:parameter 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>
       </ae:parameter>

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

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:

       <ae:parameter 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>
       </ae:parameter>

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!

| 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
Introduction to Icinga-Web | Home | Chapter 7. Advanced Topics

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