After getting a basic Icinga installation up and running in the last part, I’ll describe how to get Icinga Web, the new Ajax-powered web interface for Icinga to work. If you encounter any problems feel free to post a comment or check out the helpful Icinga Docs and Wiki.
All parts of my Icinga 1.6 As A Monitoring Solution On Ubuntu 12.04 series:
- Part 1: Basic Installation (including the Classic Web Interface)
- Part 2: Icinga Web (New Ajax Interface) [this post]
- Part 3: NagiosQL (Web-based Configuration Interface for Icinga) [coming soon]
- Part 4: Staying Up-To-Date On Host Status (external Tools)
- Part 5: Monitoring Printers (over SNMP)
- Part 6: Monitoring Windows and Linux Maschines
- Part 7: Using Icinga Data In Your Own Applications (using REST API)
1) Prerequisites
For the next steps you’ll need some additional packages (mostly PHP modules for Apache) and if you want to fetch Icinga using Git, the Git client, so let’s install them:
apt-get install php5 php5-cli php-pear php5-xmlrpc php5-xsl php5-gd php5-ldap php5-mysql (optional) apt-get install git
2) Installation
Now you’ll need the Icinga Web source. Unfortunately, at the time of this writing, there is no Ubuntu package available. I cloned the Git repository, since I wanted the upcoming 1.6.2 version of Icinga Web, however in most cases (and unless told otherwise by a developer), you’re probably better off downloading a stable package from the Icinga Website.
Using a package:
- Go to https://www.icinga.org/download/packages/ and download the latest stable version of Icinga Web to your server (e.g. using wget <url>)
- Extract the contents using
tar vfxz icinga-web-x.x.x.tar.gz
- Change into the new directory (cs icinga-web-x.x.x)
Using git:
-
git clone git://git.icinga.org/icinga-web.git
- cd icinga-web
Now it’s time to configure the installation process. If we don’t specify target directories, everything will go to /usr/local/inciga-web/.., however since we installed Icinga already using packages and therefore use the global directory structure (/etc/icinga, etc), I prefer a similar structure for Icinga Web. The following configure line will therefore make sure that Icinga Web uses /etc and /var:
./configure --with-api-cmd-file=/var/lib/icinga/rw/icinga.cmd --with-conf-dir=/etc/icinga-web --with-log-dir=/var/log/icinga-web --with-cache-dir=/var/cache/icinga-web
To compile everything, you’ll need the “make” command. In most cases this will already be installed, however on a fresh system like mine, I had to install it (and a lot of dependencies) first using
apt-get install build-essentials
Now it’s time to compile Icinga Web and add the neccessary configuration to Apache. This will create a file icinga-web.conf in /etc/apache2/conf.d containing the neccessary Alias directives.
make install make install-apache-config
Icinga Web uses the rewrite module for Apache, so let’s activate it:
a2enmod rewrite service apache2 restart
3) Configuration
Your Icinga Web installation is now accessible at /icinga-web, however it’ll greet you with a nice critical exception message. But don’t be discouraged, help is coming! :-)
Icinga Web uses it’s own tables to store information (like it’s own user database, last open crons, etc), so we need to create these tables and provide Icinga Web with the database credentials. It is recommended to use a seperate database for Icinga Web (e.g. icinga_web), however it is also possible to keep the Icinga Web tables in the same database as the rest of Icinga. I chose the second method to reduce the number of databases we have and keep it together for easier backup.
In the following instructions, I’ll use a couple of placeholders that you’ll need to replace with your actual values. The placeholders will be
- [iwuser] for the database user for your Icinga Web database. You can use the same user as IDOUtils, but it’s probably a good idea to use a different one.
- [iwpass] the password for iwuser
- [iwdb] The database name for Icinga Web. This is either the icinga database if you want to use the same as IDOUtils or for example icinga_web if you prefer to use a different database
- [idouser] This is the database username from Part 1 (usually icinga_idoutils)
- [idopass] The password for idouser, if you had one generated, you can look it up in /etc/icinga/ido2db.cfg
- [idodb] The database for IDOUtils, probably just ‘icinga’
If you want to use a different database, now would be the time to create it (either using a GUI tool like phpMyAdmin or MySQL workbench or using the “create database <name>” sql command) and grant the neccesary user rights for your [iwuser] (see the Wiki for a GRANT command, or use the GUI tool).
Icinga Web provides a SQL script to create the neccessary tables. Let’s import the schema:
mysql -u [iwuser] -p -h hostname.of.database.serv.er [iwdb] < /usr/local/icinga-web/etc/schema/mysql.sql
If your MySQL server is running locally, you can skip the hostname parameter. The command will ask you for the password of [iwuser] and afterwards create the structure in [iwdb].
Now that we installed the software, configured Apache, created a database and tables, all that’s left to do is tell Icinga Web how to connect to the database. While this sounds simple enough, it was ironically the most difficult part in my opinion. Icinga Web uses Doctrine, a database abstraction layer which is good because it dramatically increases the number of supported databases. However it also means that the configuration is stored in XML format.
The database configuration is stored in /etc/icinga-web/databases.xml (there’s also an equally named file in /usr/local/icinga-web/app/config, don’t edit that file!). In this file there are two sections, the first one to configure the icinga-web database connection, the second one for the IDOUtils database connection. All you have to change is the connection strings (in <ae:parameter name=”dsn”>). So basically change:
mysql://icinga_web:icinga_web@localhost:3306/icinga_web to mysql://[iwuser]:[iwpass]@[hostname or localhost]:3306/[iwdb] and mysql://icinga:icinga@localhost:3306/icinga to mysql://[idouser]:[idopass]@[hostname or localhost]:3306/[idodb]
Replace the placeholders with the actual values from your environment. As a reminder: The IDOUtils user and password can be found in /etc/icinga/ido2db.cfg.
Important: Uncomment both sections. XML comments start with <!– and end with –>. You can find those around each db:database tag. Just remove them so your modified configuration becomes active. This is the most likely cause if you still receive critical exceptions after you followed all steps.
The last step is to run /usr/local/icinga-web/bin/clearcache.sh to remove any configuration cache and ensure Icinga Web will load the new configuration. If you open /icinga-web now, you should be greeted with a login prompt. The default username is “root” and default password is “password”.
If you still get a critical exception, make sure you really removed the comment characters in databases.xml.
4) Using Icinga Web
Icinga Web should now be fully usable. The first thing to do is obviously to change your password. Afterwards feel free to explore Icinga Web and its cronks. Cronks are like widgets or gadgets or modules or plugins in other software, they show data or subsets of data from IDOUtils in Icinga Web. An example for a cronk would be “Unhandled service problems”.
Tackle Cronk
Icinga Web 1.6 introducted a new (experimental!) cronk named Tackle which shows a list of all your hosts with their service status as a stacked (horizontal) bar. An example can be found in the 1.6 docs. This is one of my favorite features of Icinga Web and you should definitively check it out. Unfortunately it is not stable enough to be released just yet and is therefore deactivated in the upcoming 1.6.2 release. If you want to use it anyway (and are aware that it might not work as expected yet!), you can enable it again by reversing the changeset attached to the bug issue. All you need to do is basically change “hide” and “disabled” back to false in the Tackle configuration in /usr/local/icinga-web/app/modules/Cronks/config/cronks_misc.xml. But remember, that it still is highly experimental – you’ve been warned.
This is the end of Part 2. If everything went well you should now have a working Icinga installation along with the new Icinga Web interface. Unfortunately we are still only monitoring localhost (unless you changed the configuration files yourself). The next part should take care of that however. I will show you how to install NagiosQL, a web based configuration tool for Nagios and Icinga which allows you to change or add hosts and services without getting your hands dirty with configuration files ;-)
If you have problems, suggestions or remarks, feel free to leave a comment or sent me an email.
