• ExternalLinks
Skip to end of metadata
Go to start of metadata

External Links 

This document aims to replace ICINGA notes_url or any other hacks. If you are using special html hacks to display multiple links within service status the JSON generation fails (Because of escaping and special chars) and therefore the icinga-web grid view.

Icinga-web has its own way to implement custom links based on icinga data, e.g. to display wiki pages or integrate any application (iframe or independent browser window).

Most of icinga-web views are grids bound to ICINGA data (host status, service status). This views based on ExtJS grid panels which can be configured through xml template files.

The xml located in icinga-web/app/modules/Cronks/data/xml/grid.

To modify an existing view you should follow the site configuration model: Copy the template and rename using the '.site.xml' suffix. All site configuration files are upgrade safe (Install icinga-web with make-upgrade).

Custom links are new xml definitions made in the xml templates. In most cases you only need icons to follow a new link. We providing a huge set of preconfigured icons to design your custom links.

A simple column may look like this

<field name="test_icon_link_001">
	<datasource>
		<parameter name="field">HOST_NAME</parameter>
	</datasource>

	<display>
		<parameter name="visible">true</parameter>
		<parameter name="label">&nbsp</parameter>
		<parameter name="width">20</parameter>

		<!-- Config for the AJAX grid (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.Column) -->
		<parameter name="Ext.grid.Column">
			<parameter name="fixed">true</parameter>
		</parameter>
	</display>

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

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

</field>

The field 'name' attribute have to be unique in the xml template. You need this name to build dependencies to this field (data, actions, wrapper).

Within field declaration you can use special sub declaration to configure the view or data handling. (Note the templates itself is documentation, you'll find every possible feature in the xml templates)

To add the links we only need the display section. First step is to blank the database output for 'HOST_NAME' (API column name) and display some cute icon: 

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

		<!-- Config for the AJAX grid (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.Column) -->
		<parameter name="Ext.grid.Column">
			<parameter name="fixed">true</parameter>
		</parameter>

		<parameter name="jsFunc">

			<parameter>
				<parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
				<parameter name="function">columnImage</parameter>

				<!-- renderer/gridevent[cellclick|celldblclick|...] -->
				<parameter name="type">renderer</parameter>

				<parameter name="arguments">
					<parameter name="image">images/icons/robot.png</parameter>
					<parameter name="css">x-icinga-grid-link</parameter>
					<parameter name="attr">
						<parameter name="qtip">Test tooltip</parameter>
					</parameter>
				</parameter>
			</parameter>
		</parameter>
	</display>

If you don't need images and want text instead, omit the step above and remove the 'fixed' setting or increase the width of the column.

The image renderer also adds some css class 'x-icinga-grid-link' for cursor pointer and blue underlined text.

Now we can add the event which opens a new in-line or external window with our content:

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

		<!-- Config for the AJAX grid (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.Column) -->
		<parameter name="Ext.grid.Column">
			<parameter name="fixed">true</parameter>
		</parameter>

		<parameter name="jsFunc">

			<parameter>
				<parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
				<parameter name="function">columnImage</parameter>

				<!-- renderer/gridevent[cellclick|celldblclick|...] -->
				<parameter name="type">renderer</parameter>

				<parameter name="arguments">
					<parameter name="image">images/icons/robot.png</parameter>
					<parameter name="css">x-icinga-grid-link</parameter>
					<parameter name="attr">
						<parameter name="qtip">Test tooltip</parameter>
					</parameter>
				</parameter>
			</parameter>

			<parameter>
				<parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
				<parameter name="function">iFrameCronk</parameter>
				<parameter name="type">cellclick</parameter>
				<parameter name="arguments">
					<parameter name="title">Testlink for {host_name}</parameter>
					<parameter name="url"><![CDATA[http://wiki.localhost/{host_name}/{host_object_id}]]></parameter>
					<parameter name="activateOnClick">true</parameter>
				</parameter>
			</parameter>

		</parameter>
	</display>

With this iframe cronk implementation you can seamless integrate you own application into icinga-web.

Mind the ExtJS template syntax

{FIELD_NAME}


<parameter name="url"><![CDATA[http://wiki.localhost/{host_name}/{host_object_id}]]></parameter>

to configure the title or URL for your cronk. The fieldnames are the unique xml defines in your template. Depending on which type you're working (host status, service status) you can easily parametrise the entry point of your web application.

The following example add a additional column into the icinga-host-template.xml to provide a clickable for the notes_url.

        <field name="example_host_notes_url">
             <datasource>
                <parameter name="field">HOST_NOTES_URL</parameter>
            </datasource>
            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">NOTES</parameter>
                <parameter name="jsFunc">
                    <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/book.png</parameter>
                            <parameter name="css">x-icinga-grid-link</parameter>
                            <parameter name="attr">
                                <parameter name="qtip">Click here for history</parameter>
                            </parameter>
                        </parameter>
                    </parameter>
                    <parameter>
                            <parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
                            <parameter name="function">iFrameCronk</parameter>
                            <parameter name="type">cellclick</parameter>
                            <parameter name="arguments">
                                    <parameter name="title">Test title ...</parameter>
                                    <parameter name="url"><![CDATA[{example_host_notes_url}&host={host_name}]]></parameter>
                                    <parameter name="activateOnClick">true</parameter>
                            </parameter>
                        </parameter>
                    </parameter>
            </display>
            <filter>
                <parameter name="enabled">false</parameter>
            </filter>

            <order>
                <parameter name="enabled">false</parameter>
                <parameter name="default">false</parameter>
            </order>
        </field>
  • No labels

9 Comments

  1. Anonymous

    Ok, and how does any of this solve the problem with notes_url or action_url where Icinga admins want to hard code specific URL's into the configuration files?

    Not everyone needs autogenerated URLs.

    (And frankly Icinga developers need to understand not everyone is happy dealing with great confusing blocks of XML to do what should be simple)

  2. Anonymous

    i have the same Problem with the parameter 'process_perf_data'. I would like to show the perf data icons only if there is perf data.

    With the solution described in

    https://wiki.icinga.org/display/howtos/Setting+up+PNP4Nagios+with+Icinga-Web

    i have an icon for each service.

    Is there a way to show the icon only if perf data was got.

  3. Anonymous

    This is an effective way to add a link for every host and service in icinga-web, but it does not address notes_url and action_url. This should behave similarly to icinga classic and nagios, only appearing if populated.

    Right now, anything without performance data links to an error page in pnp4nagios, which drastically increases the annoyance factor, making icinga-web somewhat unusable.

    As such, the feature ticket on action_url and notes_url that led me here, https://dev.icinga.org/issues/532, should perhaps not be 'resolved', as this workaround does not provide access to these parameters, but merely lets one specify system-wide dynamic urls.

    1. then please add a note to that dev issue, i've re-opened it for you.

      why? just because this is meant to be a wiki and not a bug / feedback tracker, the developers work with dev.icinga.org

  4. Anonymous

    I've just created a workable quick-hack for pnp4nagios, using a new icon.php controller in pnp4nagios and setting the image parameter to:

    <parameter name="image"><![CDATA[../pnp4nagios/icon?srv=

    Unknown macro: {service_name}

    &host=

    Unknown macro: {host_name}

    ]]></parameter>

    pnp4nagios/application/controllers/icon.php:

    <?php defined('SYSPATH') OR die('No direct access allowed.');
    /**
     * Icon controller - quick 'n dirty hack to display icons when perfdata is available.
     *
     */
    class Icon_Controller extends System_Controller  {

        public function __construct()
       

    Unknown macro: {        parent}

        public function index()
        {
            // Service Details
            if($this->host != "" && $this->service != ""){
                $this->service = pnp::clean($this->service);
                $this->arrow = pnp::clean($this->arrow);
                $this->host    = pnp::clean($this->host);
                $this->url     = "?host=".$this->host."&srv=".$this->service;
                $services      = $this->data->getServices($this->host);
                try {
                    $this->data->buildDataStruct($this->host,$this->service,$this->view);
                    if ($this->arrow)

    Unknown macro: {                    $img = "media/images/icons/chart--arrow.png";                }

    else

    Unknown macro: {                    $img = "media/images/icons/chart.png";                }

                    url::redirect($img,301);
                } catch (Exception $e)

    Unknown macro: {                    // too bad.. error means}

            }
        }
    }

    1. Anonymous

      hmmm, sorry i should have previewed :-(

      image parameter:

      application/controllers/icon.php
  5. Anonymous

    I want to add notes_url but macro

    Unknown macro: {host_notes_url}

    or

    Unknown macro: {notes_url}

    is blank.

    Not working:

    <parameter name="url">

    </parameter>
    <parameter name="url">

    Unknown macro: {notes_url}

    </parameter>

    1. Anonymous

      I you name the field example_host_notes_url than you can use

      Unknown macro: {example_host_notes_url}

      ... the fieldname is assigned to $HOST_NOTES_URL$

  6. Anonymous

    Hello.

    I have cfgs where I have set and used notes_url (and action_url). This hase worked fine for "older" Icinga. And we wanted to support old and new Icinga.

    I have tried to add the above described Grid Column sample and I first thought it would work fine BUT

         in my notes_url is an adress with syntax http://$HOSTADDRESS$:/...
    ...

    The $HOSTADDRESS$ will be not replaced in this grid column handling !

    What can I do ?

    (I'm no expert in Icinga-Web)

    ckae