Bernd's Interview on Icinga at Floss Weekly

Floss Weekly LogoLast Wednesday Bernd gave an interview on Icinga to Randal L. Schwartz from Floss Weekly, a free software/open source theme podcast. Since 2010, Randal is the lead host of this show where he interviews every week influential OS experts from over the world. In this interview, Bernd explained the main differences between Nagios and Icinga as well as the advantages of Icinga 2 over them and its API. Randal and his co-host Guillermo Amaral, asked questions about monitoring in general with Icinga 2, integration with other tools and future prospects.
If you want to know more about it, check out the interview!

Icinga Web 2 – Where to go today?

Since Alexander showed you how to create a new module for Icinga Web 2 pretty easily (German) some time ago, I’ll continue this today by describing how to add some basic navigation elements to the Hello World-Module.
So we’re currently here:

Subsidiary Menu Entries

To split up our main menu entry on the left hand into additional topics we need to take another look at the configuration.php file:

<?php
$section = $this->menuSection('Hello World', array(
    'url' => 'helloworld'
));

We’ll split it up into two entries in this example:

<?php
$section = $this->menuSection('Hello', array(
    'icon'  => 'globe'
));
$section->add('World', array(
    'url'       => 'helloworld',
    'priority'  => 100
));
$section->add('Universe', array(
    'url'       => 'helloworld/universe',
    'priority'  => 101
));

Who’s taking a closer look will probably notice that our main menu entry doesn’t point to a URL anymore. It’s just a simple entry now whose main purpose is to group other entries together and to expand them once the user clicks on it. But on the other hand it has got a neat icon so that it suits the surrounding entries properly. The two new entries are introducing a new property which is being used to adjust the order of an entry as by default they are in alphabetical order.
The menu should now look as follows:

Tabs

In case another menu entry is not applicable it’s also possible to show some tabs in our views. For convenience’ sake or because I can’t think of an alternative right now we’ll add both menu entries we’ve created earlier again, but this time as tabs. Let’s take a look a the IndexController:

<?php
use Icinga\Web\Controller\ModuleActionController;
class HelloWorld_IndexController extends ModuleActionController
{
    public function indexAction()
    {
        $this->getTabs()->activate('world');
    }
    public function getTabs()
    {
        $tabs = parent::getTabs();
        $tabs->add(
            'world',
            array(
                'title' => 'World',
                'url'   => 'helloworld'
            )
        );
        $tabs->add(
            'universe',
            array(
                'title' => 'Universe',
                'url'   => 'helloworld/universe'
            )
        );
        return $tabs;
    }
}

To actually show the tabs in our view we’ll need to extend the view script for the indexAction: (index.phtml)

<?php if (! $this->compact): ?>
<div class="controls">
  <?= $tabs; ?>
</div>
<?php endif ?>
<div class="content">
  <h1>Hello World</h1>
</div>

You should consider the new template as a convention. No one forces you to use it but doing it exactly this way you’ll make sure that your view is looking properly when being viewed in full-screen mode or on the dashboard.
Due to the fact that the menu entry and tab for the universe is currently leading into the void.. we need to create a controller for this route. To accomplish this we’ll create a new file called UniverseController.php and the respective view script:

<?php
use Icinga\Web\Controller\ModuleActionController;
class HelloWorld_UniverseController extends ModuleActionController
{
    public function indexAction()
    {
        $this->getTabs()->activate('universe');
    }
    public function getTabs()
    {
        $tabs = parent::getTabs();
        $tabs->add(
            'world',
            array(
                'title' => 'World',
                'url'   => 'helloworld'
            )
        );
        $tabs->add(
            'universe',
            array(
                'title' => 'Universe',
                'url'   => 'helloworld/universe'
            )
        );
        return $tabs;
    }
}
<?php if (! $this->compact): ?>
<div class="controls">
  <?= $tabs; ?>
</div>
<?php endif ?>
<div class="content">
  <h1>Hello Universe</h1>
</div>

The file structure should now look as follows:

Columns

Who’s using the monitoring module has probably noticed that not all URLs cause a complete change of context, but are causing Icinga Web 2 to open a new column on your screen. Now to prevent our new route, which we’re going to define, from changing the context we’ll need to change this explicitly.
UniverseController.php

// *Snip*
    public function galaxyAction()
    {
        $galaxy = $this->params->getRequired('galaxy');
        $this->view->galaxy = $galaxy;
    }
    public function getTabs()
// *Snip*

views/scripts/universe/galaxy.phtml

<?php if (! $this->compact): ?>
<div class="controls">
  <?= $tabs->showOnlyCloseButton(); ?>
</div>
<?php endif ?>
<div class="content">
  <h1>Hello <?= $galaxy; ?></h1>
</div>

views/scripts/universe/index.phtml

<!-- *Snip* -->
  <h1>Hello Universe</h1>
  <?= $this->qlink('Greet the Milky Way', 'helloworld/universe/galaxy', array('galaxy' => 'Milky Way')); ?>
  <br>
  <?= $this->qlink('Greet Andromeda', 'helloworld/universe/galaxy', array('galaxy' => 'Andromeda')); ?>
</div>

To greet a galaxy in a new column we’ll have to apply the following change in the view script above:
views/scripts/universe/index.phtml

<!-- *Snip* -->
<div class="content" data-base-target="_next">
<!-- *Snip* -->

This data- attribute accepts the following values:

Value Description
_main Use the first column and close all others (Default)
_self Use the current column, all others are kept as is
_next Use a new column at the right and close the first left column if there’s not enough space available
<id> Use the container with the id <id>. This can be either any HTML-container or one of the predefined column ids: col1, col2

Usage of this attribute is not limited to a specific sub-set of HTML elements and it can be nested freely. This means that only the most significant attribute is being considered when a URL is processed by Icinga Web 2. (e.g. <div data-base-target=”_next”><a data-base-target=”_self” …></a></div> _self is more significant than _next)
We’ve now arrived at the end of this guide. I hope it is informative enough but if there are still questions I’ll recommend you to ask us (me) on the forums. Thanks, see you next time!

New features in Icinga 2.3

The next major version of Icinga 2 will introduce a bunch of interesting features which should make it even easier to define exceptions for services (as in, all services have a check_interval of 5 minutes except for…). Version 2.3 won’t be available for another couple of weeks but here’s a quick introduction to some of its features:

Conditional Statements

More commonly known as if/else: In 2.3 it’s possible to set attributes based on whether some condition is true. Here’s an example:

object Host "localhost" {
  check_command = "hostalive"
  address = "127.0.0.1"
  vars.http_vhosts["icinga.org"] = {
    http_address = "icinga.org"
    interval = 1m
  }
  vars.http_vhosts["dev.icinga.com"] = {
    http_address = "dev.icinga.com"
  }
}
apply Service "vhost " for (vhost => config in host.vars.http_vhosts) {
  host_name = "localhost"
  check_command = "http"
  if (config.interval) {
    check_interval = config.interval
  } else {
    check_interval = 5m
  }
  assign where host.vars.http_vhosts
}

Debug Console

In order to make testing filter rules for “apply” as well as other expressions easier we have implemented a CLI-based console which can be used to evaluate arbitrary expressions and show their results:

$ icinga2 console
Icinga (version: v2.2.0-282-g9898971)
<1> => config = { http_address = "icinga.org", interval = 1m }
null
<2> => if (config.interval) { check_interval = config.interval } else { check_interval = 5m }
null
<3> => check_interval
60.0

Prototypes

All built-in data types (i.e. strings, numbers, arrays and dictionaries) now have their own methods. Here’s an example how we can use those methods to manipulate dictionaries:

<1> => vhosts = { "icinga.org" = { http_address = "icinga.org" },
"dev.icinga.com" = { http_address = "dev.icinga.com" } }
null
<2> => vhosts.remove("icinga.org")
null
<3> => vhosts
{"dev.icinga.com":{"http_address":"dev.icinga.com"}}
<4> => vhosts.len()
1.0

Using Dictionary#remove we can remove specific dictionary items which is rather useful if those dictionary keys should not be set for some hosts or services.

Analysing configuration problems with Icinga 2

In order to make it even easier to find configuration mistakes we’re going to provide a new tool as part of the upcoming Icinga 2.1 release:

# icinga2-list-objects
Object 'api' of type 'ApiListener':
  * templates = ['api']
    % modified in /etc/icinga2/features-enabled/api.conf, lines 5:1-11:1
  * bind_port = '5665'
    % modified in /etc/icinga2/features-enabled/api.conf, lines 10:3-10:20
  * __name = 'api'
  * ca_path = '/etc/icinga2/pki/ca.crt'
    % modified in /etc/icinga2/features-enabled/api.conf, lines 8:3-8:46
  * cert_path = '/etc/icinga2/pki/ztv.beutner.name.crt'
    % modified in /etc/icinga2/features-enabled/api.conf, lines 6:3-6:62
  * type = 'ApiListener'
  * key_path = '/etc/icinga2/pki/ztv.beutner.name.key'
    % modified in /etc/icinga2/features-enabled/api.conf, lines 7:3-7:61
[...]

The “icinga2-list-objects” tool lists all configuration objects. This includes objects which have been created using “apply” rules and should help with diagnosing whether your rules work as you expect them to.
In addition to the objects we’re also listing all attributes and their values. Icinga 2 also keeps track of where exactly each attribute was modified.

Icinga Releases & GIT Mirror now on GitHub

Dear community,
Yesterday we migrated our mailing lists away from Sourceforge. Today it’s time to migrate our release downloads. You may wonder why we are leaving a feature rich and free platform. The answer is simple – Sourceforge has grown to be too bloated with ads for our liking. Not only on their website and mailing list footers, but also by wrapping popular tools with their advertising installer. We do not want this to happen to Icinga or our users, and have therefore sought out possible alternatives.
Many community members have asked us “Why don’t you use GitHub for development?”. Though GitHub offers a complete toolstack for development, we still prefer our set of tools – Redmine for issue tracking & development organisation, deeply integrated with the existing Git server and its hooks, and further, Confluence as feature-rich wiki alternative. However, there is one big advantage to using GitHub – forks & pull requests make sending patches easier for everyone.
That’s primarly the reason why we’re now hosting a Git mirror on GitHub available at https://github.com/Icinga. Fork Icinga, send pull requests. But please be sure to notify Icinga developers using our Development Tracker by creating a new issue. Releases will continue to be organized in Redmine; something we won’t change thanks to 5 years of habit, sorry 😉
Furthermore GitHub offers a release feature – Git tags are automatically available as archive downloads. While this hurts in some areas (‘icinga-core-1.10.0’ vs ‘icinga-1.10.0’), we’ve found a subtle solution for that: All releases contain an additional binary, are verified ok & uploaded by the Icinga release manager(s) ensuring the quality of the release process 🙂
For example, if you want to download Icinga 1.10.2, then follow this url (or use the version identifier for a more direct approach). Then click the green download  “icinga-1.10.2.tar.gz” button as shown in the image below:
github_release_tag_edit_04
 
All future releases (Icinga 1.11, Icinga 2, Icinga Web 2) will be uploaded to our new release platform. Thanks to GitHub for an awesome free service!
P.S.: We are in the process of migrating existing virtual appliances into a new style of demo boxes, much like the existing Icinga 2 Vagrant box 🙂

Christmas Wishes for Icinga 2

With our recent Icinga 2 v0.0.6 release, we managed to tick off one Christmas wish from last year – recurring downtimes, and just in the nick of time.
While the momentum is strong, we thought we’d ask… What would you like most of all for Icinga 2 in 2014?
[poll id=”13″]
We hope you were good this year, ’cause we’d like some of these wishes to come true too 😉
Xmas_2014