Today the icinga team released the first stable version of their open source monitoring tool – Icinga 1.0.
The team behind icinga formed up earlier this year and forked nagios due to several reasons.
In this small howto i’d like to describe the installation of Icinga in cooperation with IDOUtils and NConf for easier configuration of multiple hosts and services on a fresh debian system:
- Install some prequisites:
apt-get install apache2 build-essential libgd2-xpm-dev libjpeg62 libjpeg62-dev libpng12 libpng12-dev mysql-server mysql-client libdbi0 libdbi0-dev libdbd-mysql libdbi-perl libdbd-mysql-perl
- As root, add an user and group for icinga:
/usr/sbin/useradd -m icinga && /usr/sbin/groupadd icinga
- Download icinga-core 1.0 (not icinga-web) from the icinga download site
- Unpack the downloaded archive, for example in a new directory called /usr/local/icinga with the command
tar xzfv icinga-1.0.tar.gz
- Enter the new directory and configure icinga with
./configure –enable-idoutils
- General options should look like this:
General Options:
————————-
Icinga executable: icinga
Icinga user/group: icinga,icinga
Command user/group: icinga,icinga
Embedded Perl: no
Event Broker: yes
Build IDOUtils: yes
Install ${prefix}: /usr/local/icinga
Lock file: ${prefix}/var/icinga.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/apache2/conf.d
Mail program: /usr/bin/mail
Host OS: linux-gnu - Compile the icinga source code with
make all
- If everything went fine, just install icinga completely with
make fullinstall
- Time for some customization:
comment out all cfg_file options from line 30 to line 36 of icinga.cfg, they´ll be provided by NConf later:# You can specify individual object config files as shown below:
#cfg_file=/usr/local/icinga/etc/objects/commands.cfg
#cfg_file=/usr/local/icinga/etc/objects/contacts.cfg
#cfg_file=/usr/local/icinga/etc/objects/timeperiods.cfg
#cfg_file=/usr/local/icinga/etc/objects/templates.cfg# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/icinga/etc/objects/localhost.cfg# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/icinga/etc/objects/windows.cfg# Definitions for monitoring a router/switch
#cfg_file=/usr/local/icinga/etc/objects/switch.cfg# Definitions for monitoring a network printer
#cfg_file=/usr/local/icinga/etc/objects/printer.cfg - Add two new cfg_dir options for NConf:
cfg_dir=/usr/local/icinga/etc/objects/global
cfg_dir=/usr/local/icinga/etc/objects/Default_collector/ - uncomment broker_module in line 251:
broker_module=/usr/local/icinga/bin/idomod.o config_file=/usr/local/icinga/etc/idomod.cfg
- In /usr/local/icinga/etc directrory, create IDOUtils sampe configuration:
cp idomod.cfg-sample idomod.cfg
cp ido2db.cfg-sample ido2db.cfg - Generate MySQL Database and User for icinga
# mysql -u root -p
mysql> CREATE DATABASE icinga;
GRANT USAGE ON \*.\* TO ‘icinga’@'localhost’ IDENTIFIED BY ‘MYSUPERHEROPASSWORD’ WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
GRANT ALL PRIVILEGES ON icinga.\* TO ‘icinga’@'localhost’;FLUSH PRIVILEGES ;
quit - Import corresponding database scheme for MySQL:
# cd /path/to/icinga-src/module/idoutils/db
# mysql -u root -p icinga < mysql.sql - Customize database credentials in /usr/local/icinga/etc/ido2db.cfg
and take care of the following options:db_servertype=mysql
db_port=3306
db_user=icinga
db_pass=MYSUPERHEROPASSWORD - Change .htaccess password for the icingaadmin: htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
- Copy sample configuration for apache:
cp /usr/local/icinga/icinga-1.0/sample-config/httpd.conf /etc/apache2/conf.d/icinga.conf
- Download latest NConf release from the NConf download page
- Unpack the archive in one of your web directories, e.g. in /var/www/nconf
tar xzfv nconf-1.2.6-0.tgz
- Make the new directory read/writeable to your webserver:
chown -R www-data:www-data nconf/
- Create new file nconf.conf in /etc/apache2/conf.d:
#nconf.conf
Alias /nconf "/var/www/virtual/nconf"# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Icinga Access"
AuthType Basic
AuthUserFile /usr/local/icinga/etc/htpasswd.users
Require valid-user
- Reload apache
- Create database and user for NConf:
# mysql -u root -p
mysql> CREATE DATABASE nconf;
GRANT USAGE ON \*.\* TO ‘nconf’@'localhost’ IDENTIFIED BY ‘MYSUPERHEROPASSWORD’ WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
GRANT ALL PRIVILEGES ON nconf.\* TO ‘nconf’@'localhost’;
FLUSH PRIVILEGES ;
quit - Complete installation via NConf Web Gui, for example on
- Put /usr/local/icinga/bin/icinga as NAGIOS_BIN
- Configure your hosts and services in the NConf WebGui
- make sure to delete the host and service notification state "[n]" editing your contacts, otherwise you won’t get any notification.
- Edit the notify-host-by-email/notify-sercice-by-email command in misccommands section in order to point to the corresponding binary for the mail command, in my case /usr/bin/mail
- After finishing host and services configuration, hit the Generate Nagios config Button.
- Your nagios configuration is now saved in the /output directory of your NConf installation.
- customize NConf deploy script in /var/www/virtualnconf/ADD-ONS/deploy_local.sh, for example:
#!/bin/bash
OUTPUT_DIR="/var/www/virtual/nconf/output/"
NAGIOS_DIR="/usr/local/icinga/etc/objects/"
TEMP_DIR=${NAGIOS_DIR}"import/"
CONF_ARCHIVE="NagiosConfig.tgz"if [ ! -e ${TEMP_DIR} ] ; then
mkdir -p ${TEMP_DIR}
fiif [ ${OUTPUT_DIR}${CONF_ARCHIVE} -nt ${TEMP_DIR}${CONF_ARCHIVE} ] ; then
cp -p ${OUTPUT_DIR}${CONF_ARCHIVE} ${TEMP_DIR}${CONF_ARCHIVE}
tar -xf ${TEMP_DIR}${CONF_ARCHIVE} -C ${NAGIOS_DIR}
/etc/init.d/icinga reload
fiexit
- Configure cronjob to refresh your configuration regulary, if you want to
*/10 * * * * /var/www/virtual/nconf/ADD-ONS/deploy_local.sh
- Start IDOUtils:
/etc/init.d/ido2db start
- Start Icinga:
/etc/init.d/icinga start
- Check icinga.log logfile in /usr/local/icinga/var
- Be Happy!
/etc/init.d/apache2 reload
For more information on Icinga and IDOUtils check out the documentation.
More information on NConf is available in the NConf documentation.