Installation of Icinga and Adagios

Throughout the years I have installed a bunch of Icinga + Adagios installations. Now, I know that Icinga2 with their own Web Configurator is out there, but Icinga is still a rock solid Nagios solution with tons of scripts ready to be used. In combination with Adagios for the configuration part, it’s hard to find a competitive free alternative.

I have kept the following guide for my self just as a quick installation guide, but finally thought it would be nice to share it with the community. Now, it’s not a bullet proof guide and you need to know the basics of Linux and troubleshooting. But I hope it can be a great help to put it all together.

The guide is tested on Debian 8 and the corresponding Ubuntu systems. It will not work on Debian 9 – already tried that.

Installation of Icinga

Run the following commands

apt-get install python-software-properties

add-apt-repository ppa:formorer/icinga

apt-get update

apt-get install icinga icinga-doc icinga-idoutils mysql-server libdbd-mysql mysql-client nagios-plugins* php5 php5-cli php-pear php5-xmlrpc php5-xsl php5-gd php5-ldap php5-mysql

When prompted, enter the folling information

MySQL root password: ***
FQDN: domain.ltd
Smart Host: mail.domain.ltd
Icinga Admin: ***
External Commands: yes
icinga-idoutils with dbconfig-common: yes
Database Type: mysql
MySQL root password: ***
icinga-idoutils: ***

Run the following commands

sed -i 's|IDO2DB=no|IDO2DB=yes|;' /etc/default/icinga

/etc/init.d/ido2db restart

cp /usr/share/doc/icinga-idoutils/examples/idoutils.cfg-sample /etc/icinga/modules/idoutils.cfg

/etc/init.d/icinga restart

apt-get install phpmyadmin

When prompted, enter the folling information

dbconfig-common: yes
MySQL root password: ***
phpmyadmin password: ***
Web server: apache2

Edit /etc/phpmyadmin/config.inc.php with the following

$cfg['ForceSSL'] = true;

Run the following commands

php5enmod mcrypt

a2enmod ssl

ln -s ../sites-available/default-ssl.conf default-ssl.conf

service apache2 restart

Installation of Adagios

Run the following commands

apt-get install git python-pip apache2 libapache2-mod-wsgi python-django python-simplejson pnp4nagios libgmp-dev python-dev python-paramiko check-mk-livestatus

cd /usr/local/src

git clone https://github.com/pynag/pynag.git

cd pynag

python setup.py build

python setup.py install

ln -s /usr/local/lib/python2.7/dist-packages/adagios/etc/adagios/ /etc/adagios

chown nagios -R /etc/adagios/

mkdir /etc/icinga/adagios

chown nagios:www-data -R /etc/icinga/adagios

sed -i 's|/etc/nagios/nagios.cfg|/etc/icinga/icinga.cfg|;' /etc/adagios/adagios.conf

sed -i 's|sudo /etc/init.d/nagios|sudo /etc/init.d/icinga|;' /etc/adagios/adagios.conf

sed -i 's|nagios_url = "/nagios"|nagios_url = "/icinga"|;' /etc/adagios/adagios.conf

sed -i 's|destination_directory = "/etc/nagios/adagios/"|destination_directory = "/etc/icinga/adagios/"|;' /etc/adagios/adagios.conf

sed -i 's|nagios_binary="/usr/sbin/nagios"|nagios_binary="/usr/sbin/icinga"|;' /etc/adagios/adagios.conf

sed -i 's|pnp_filepath="/usr/share/nagios/html/pnp4nagios/index.php"|pnp_filepath="/usr/share/pnp4nagios/html/index.php"|;' /etc/adagios/adagios.conf

pynag config --append "broker_module=/usr/lib/check_mk/livestatus.o /var/lib/icinga/rw/livestatus"

pynag config --append cfg_dir=/etc/adagios

service icinga reload

Edit /etc/apache2/conf-available/adagios.conf with the following

WSGISocketPrefix /var/run/apache2/wsgi

WSGIDaemonProcess adagios user=nagios group=nagios processes=1 threads=25 python-path=/opt/adagios:/opt/adagios/adagios

WSGIProcessGroup adagios

WSGIScriptAlias /adagios /usr/local/lib/python2.7/dist-packages/adagios/apache/adagios.wsgi

Alias /adagios/media /usr/local/lib/python2.7/dist-packages/adagios/media


    AuthName "Adagios Access"
    AuthType Basic
    AuthUserFile /etc/icinga/htpasswd.users
    Require valid-user

Run the following commands

cd /etc/apache2/conf-enabled

ln -s ../conf-available/adagios.conf adagios.conf

service apache2 restart

cd /usr/local/src

git clone https://github.com/opinkerfi/okconfig.git

cp -arv okconfig/ /opt/

cd /opt

bash -c "echo 'export PYTHONPATH=$PYTHONPATH:/opt/okconfig' > /etc/profile.d/okconfig.sh"

cp -av /opt/okconfig/etc/okconfig.conf /etc/okconfig.conf

bash -c 'source /etc/profile'

mkdir /etc/icinga/okconfig/

chown nagios:www-data /etc/icinga/okconfig

ln -s /opt/okconfig/usr/share/okconfig /usr/share/

ln -s /opt/okconfig/usr/bin/okconfig /usr/local/bin/

sed -i 's|/etc/nagios/nagios.cfg|/etc/icinga/icinga.cfg|;' /etc/okconfig.conf

sed -i 's|/etc/nagios/okconfig|/etc/icinga/okconfig|;' /etc/okconfig.conf

sed -i 's|/etc/nagios/okconfig/examples|/etc/icinga/okconfig/examples|;' /etc/okconfig.conf

cd okconfig

python setup.py install

chown nagios:www-data /etc/icinga/*.cfg

chmod 755 /etc/icinga -R

chmod 760 /etc/icinga/*.cfg

chown -R nagios:www-data /etc/icinga/objects

chmod -R 775 /etc/icinga/objects

okconfig init

okconfig verify

cd /etc/icinga

git init

git add .

git commit -a -m "Initial commit"

git config user.name "Icinga"

git config user.email "icinga@domain.ltd"

mkdir /var/lib/adagios

chown nagios:www-data /var/lib/adagios

chmod 775 /var/lib/adagios

Edit /etc/icinga/icinga.cfg with the following

cfg_dir=/etc/icinga/adagios

Run the following commands

chown -R nagios:www-data /etc/icinga/.git

chmod -R 775 /etc/icinga/.git

Run visudo and add the following

# Icinga daemon control
Defaults:nagios !requiretty
nagios ALL = (root) NOPASSWD: /etc/init.d/icinga

Run the following commands

/etc/init.d/apache2 restart

/etc/init.d/icinga restart

Installation of pnp4nagios

Run the following commands

cd /etc/apache2/conf-available/

ln -s ../../pnp4nagios/apache.conf pnp4nagios.conf

cd ../conf-enabled/

ln -s ../conf-available/pnp4nagios.conf pnp4nagios.conf

service apache2 restart

Edit /etc/icinga/icinga.cfg with the following

process_performance_data=1

service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$

host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$

service_perfdata_file_mode=a
host_perfdata_file_mode=a

service_perfdata_file_processing_interval=30
host_perfdata_file_processing_interval=30

service_perfdata_file_processing_command=pnp-bulknpcd-service
host_perfdata_file_processing_command=pnp-bulknpcd-host

service_perfdata_file=/var/spool/pnp4nagios/nagios/service-perfdata
host_perfdata_file=/var/spool/pnp4nagios/nagios/host-perfdata

Edit /etc/icinga/commands.cfg with the following

# php4nagios commands
define command {
    command_name    pnp-bulknpcd-service
    command_line    /bin/mv /var/spool/pnp4nagios/nagios/service-perfdata
    /var/spool/pnp4nagios/npcd/service-perfdata.$TIMET$
}

define command {
    command_name    pnp-bulknpcd-host
    command_line       /bin/mv /var/spool/pnp4nagios/nagios/host-perfdata /var/spool/pnp4nagios/npcd/host-perfdata.$TIMET$
}

Run the following commands

sed -i 's|Nagios|Icinga|;' /etc/apache2/conf-available/pnp4nagios.conf

sed -i 's|/etc/nagios3/htpasswd.users|/etc/icinga/htpasswd.users|;' /etc/apache2/conf-available/pnp4nagios.conf

/etc/init.d/apache2 restart

sed -i 's|RUN="no"|RUN="yes"|;' /etc/default/npcd

/etc/init.d/npcd restart

/etc/init.d/icinga restart

Edit /etc/pnp4nagios/config.php with the following

$conf['nagios_base'] = "icinga/cgi-bin";

Edit /etc/icinga/pnptemplate.cfg with the following

define host {
    name            pnp-hst
    register        0
    action_url   /pnp4nagios/index.php/graph?host=$HOSTNAME$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=_HOST_
}

define service {
    name           pnp-svc
    register       0
    action_url   /pnp4nagios/index.php/graph host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
}

Edit /etc/icinga/icinga.cfg with the following

cfg_file=/etc/icinga/pnptemplate.cfg

Run the following commands

/etc/init.d/icinga restart

Add the newly created pnp-templates under hosts and services (pnp-hst respectively pnp-svc).

Leave a Reply

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