How to monitor your MySQL server(s) with Icinga 2

Are you responsible for one or more MySQL servers in your company or organisation? Do you run a MySQL replication setup or multiple MySQL instances on your machine? Then you probably want to know if they are performing as well as they could do and if you’re getting the most out of your hardware. Monitoring your MySQL server(s) provides valuable information — both for avoiding and dealing with problems. If you’re looking for a free and open-source solution, then it’s time to learn our tips and tricks for monitoring MySQL with Icinga 2.

This document introduces the necessary monitoring plugins and shows some Icinga 2 configuration examples for monitoring various MySQL setups, from single servers to master/slave setups with replication, to multiple MySQL instances on a single server.

Tip: All sample listings can also apply to MariaDB and Percona Server. So, whenever we talk about MySQL, this includes the two spin-offs. (more…)

Create your own Icinga Book

Like many other Open Source projects, the Icinga team uses GitHub as its hosting service. Over 25 different repositories contain our monitoring software Icinga 2, the web interface Icinga Web 2, Docker containers and Vagrant boxes, various modules, etc. Some of the repositories offer simple installation instructions and configuration examples (README.md), others contain a subdirectory called doc with more detailed instructions and several files.

To create a handbook for offline viewing, you don’t need to copy & paste the content of all the files into your favourite text editor or word processor and start from scratch. All of the guides are written in Markdown, a lightweight markup language with plain text formatting syntax, and it is quite easy to convert them to other formats like plain or rich text, HTML, HTML5, Wiki markup (MediaWiki), LaTeX, PDF, ODT, or EPUB. All you need is a little commandline tool called Pandoc .
(more…)

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:
module-final

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:
Subsidiary Menu Entries

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:
helloworld-neue-dateien

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!

Icinga 2 SELinux policy looking for testers

selinux-penguin-125

After discussing with Michael at FOSDEM about confining Icinga 2 with its own SELinux policy I took over this task. After two months of hard work it’s looking good and requires your test feedback.

 

Who?

The main target is creating a policy package for Red Hat Enterprise Linux 7 and its derivates, so if you are running one of those with SELinux enabled, consider yourself invited. If you are running a different operating system with SELinux enabled and you want to give the policy a try you are  of course welcome too.

Test – but what?

Simply follow the installation instructions to install the SELinux policy package and run Icinga 2 like normal. It does not matter if you are running a small setup or a complex environment – every little feedback counts and will help making the policy ready for production. Also please verify and report everything working as expected. If the documentation is unclear, let us know with in detail and best with your proposals. Add all the feedback to the feature request which tracks the development.

More?

SELinux Coloring Book

Want to know more about before getting your hands dirty on testing? The documentation contains links to the SELinux FAQ, the Red Hat Enterprise Linux 7 – SELinux User’s and Administrator’s Guide and perhaps the best resource the SELinux Coloring Book for those starting with SELinux. The documentation should explain the SELinux policy package which confines the Icinga 2 daemon and also allows to confine an administrative account for only managing Icinga 2.

Why?

Why should you care about SELinux? Simply because it adds an additional layer of security which mitigates the impact of vulnerabilities. For example, not to long ago and perhaps well remembered have a look at Dan Walsh analyse of shellshock.

Next steps

Collecting your feedback and improving the policy and its documentation comes first. After that the RPM spec file will be modified providing the policy as separate package, ensuring that the final installation will be easy as pie. Once everything is reviewed, the development branch will be merged targeting Icinga 2 version 2.4.

Fedora and EPEL packagers may then start their review requests in order to bring Icinga 2 into their repositories.

Similar to the process of enabling Icinga 2 with SELinux, there’s more to do with Icinga Web 2 once it is released in its stable version.

Last but not least all the created policies should qualify for the upstream reference policy which means no extra installation packages required.

 

For a German version of this post have a look at the Netways blog.

Icinga 2 in iX Magazine Special Issue

ix_magazine_Icinga2_coverIcinga 2 has been featured in a special issue of the German language iX Magazine.

Written by our very own Icinga 2 developer, Michael Friedrich ‘Systems Monitoring with Icinga 2 – In Full View’ offers a neatly packaged introduction to Icinga 2, it’s capabilities and how to get them running.

Beginning with installation and configuration basics, the article gives a few tips on working with new object-based, template driven format. It continues with the integration of Icinga Web 2 for visualization and Graphite for real-time performance monitoring. Finally, for the more complex environments, Michael explains how Icinga 2 clusters can be configured for distributed monitoring out-of-the-box.

To top it all off, the print article comes with a virtual machine (on DVD) preconfigured with Icinga 2, Graphite and a preview version of Icinga Web 2 for you to play with.

For those who have not yet taken the plunge into Icinga 2, the article is a great way to get your toes wet.

Happy reading!