System Monitoring with Icinga2

I’ve been using Icinga2 to monitor some servers we have at work for a little while now but I’ve never really got into it properly.
The time has come to setup some proper monitoring for our infrastructure so I figured I’d document it properly to help anyone with the problems I had.
The instructions that are given on the icinga website (http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/getting-started#setting-up-icinga2) do a pretty good job of getting it up and running but I had to add a few extra steps for the installation on Ubuntu 14.04 LTS.
The commands run were as follows:

add-apt-repository ppa:formorer/icinga
apt-get update
apt-get install icinga2
apt-get install nagios-nrpe-server nagios-plugins
usermod -a -G nagios www-data
apt-get install mysql-server mysql-client
apt-get install icinga2-ido-mysql
mysql -u root -p
  mysql> CREATE DATABASE icinga;
  mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';
mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
icinga2 feature enable ido-mysql
icinga2 feature enable command
service icinga2 restart

That’s got Icinga2 installed. Now for the web access. Again, there’s a pretty good guide here but I’ll walk you through it anyway.

wget -O - http://packages.icinga.org/icinga.key | apt-key add -
add-apt-repository 'deb http://packages.icinga.org/ubuntu icinga-trusty main'
apt-get update

Now here’s where I ran into some trouble. I got this error:

W: GPG error: http://packages.icinga.org icinga-trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C6E319C334410682

This can easily be fixed by running the following command:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C6E319C334410682
apt-get update

Try the update again and install IcingaWeb2

apt-get install icingaweb2

You can then navigate to your icinga2 installation at http:///icingaweb2/setup
You’re going to need to run a few more commands however.

usermod -a -G icingaweb2 www-data
icingacli setup config directory --group icingaweb2
icingacli setup token create

This will then generate a token which you have to enter on the icingaweb2 setup page.
After you click next, the installer will inform you of any configuration changes that are required. You don’t have to fix all the errors now but it may well cause you a headache later on so just go ahead and fix what you need to. I had to enter a timezone in my php.ini file and install the following PHP modules:

apt-get install php5-intl php5-gd php5-imagick php5-pgsql

Restart the apache webserver and regresh the setup page and all your modules should now show up green and verified!

Leave a Comment

Your email address will not be published. Required fields are marked *