Installing Icinga 1.0 with IDOUtils and NConf

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:

  1. 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

  2. As root, add an user and group for icinga:

    /usr/sbin/useradd -m icinga && /usr/sbin/groupadd icinga

  3. Download icinga-core 1.0 (not icinga-web) from the icinga download site
  4. Unpack the downloaded archive, for example in a new directory called /usr/local/icinga with the command

    tar xzfv icinga-1.0.tar.gz

  5. Enter the new directory and configure icinga with
    ./configure –enable-idoutils

  6. 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

  7. Compile the icinga source code with

    make all

  8. If everything went fine, just install icinga completely with

    make fullinstall

  9. 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

  10. 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/

  11. uncomment broker_module in line 251:

    broker_module=/usr/local/icinga/bin/idomod.o config_file=/usr/local/icinga/etc/idomod.cfg

  12. In /usr/local/icinga/etc directrory, create IDOUtils sampe configuration:

    cp idomod.cfg-sample idomod.cfg
    cp ido2db.cfg-sample ido2db.cfg

  13. 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

  14. Import corresponding database scheme for MySQL:

    # cd /path/to/icinga-src/module/idoutils/db
    # mysql -u root -p icinga < mysql.sql

  15. 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

  16. Change .htaccess password for the icingaadmin: htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
  17. Copy sample configuration for apache:

    cp /usr/local/icinga/icinga-1.0/sample-config/httpd.conf /etc/apache2/conf.d/icinga.conf

  18. Download latest NConf release from the NConf download page
  19. Unpack the archive in one of your web directories, e.g. in /var/www/nconf

    tar xzfv nconf-1.2.6-0.tgz

  20. Make the new directory read/writeable to your webserver:

    chown -R www-data:www-data nconf/

  21. 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

  22. Reload apache
  23. /etc/init.d/apache2 reload

  24. 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

  25. Complete installation via NConf Web Gui, for example on
  26. Put /usr/local/icinga/bin/icinga as NAGIOS_BIN
  27. Configure your hosts and services in the NConf WebGui
  28. make sure to delete the host and service notification state "[n]" editing your contacts, otherwise you won’t get any notification.
  29. 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
  30. After finishing host and services configuration, hit the Generate Nagios config Button.
  31. Your nagios configuration is now saved in the /output directory of your NConf installation.
  32. 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}
    fi

    if [ ${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
    fi

    exit

  33. Configure cronjob to refresh your configuration regulary, if you want to

    */10 * * * * /var/www/virtual/nconf/ADD-ONS/deploy_local.sh

  34. Start IDOUtils:

    /etc/init.d/ido2db start

  35. Start Icinga:

    /etc/init.d/icinga start

  36. Check icinga.log logfile in /usr/local/icinga/var
  37. Be Happy!
    1. For more information on Icinga and IDOUtils check out the documentation.
      More information on NConf is available in the NConf documentation.

Related Posts:

Auf zur Open Source Datacenter Conference in Nürnberg

Über einen Beitrag von Kris wurden Martin und ich auf die Open Source Datacenter Conference in Nürnburg aufmerksam und haben natürlich gleich beim “Early Bird” Ticket zugeschlagen!
OSDC über sich selbst:

Die OSDC ist eine Konferenz zum Thema Einsatz von Open Source Software in Rechenzentren und großen IT Umgebungen, die sich insbesondere an erfahrene Administratoren und Architekten richtet.

Ich persönlich freue mich auf Vorträge zu MySQL in großen Umgebungen, Puppet, Kickstart und andere Vorträge und Workshops zu Themen wie Load Balancing, High Availibility, Clustering uvm. Das vorläufige Vortragsprogramm findet man hier.
Die Conference findet am 29/30.April 2009 im “NH Nürnberg-City” in der Nürnberger Stadtmitte statt.
Ausser den Vorträgen werden wir uns sicherlich das eine oder andere Bierchen unter Ex-Kollegen gönnen :)

Related Posts: