Skip to content

Installing Adagios from source on Debian

jlaxdal edited this page Jul 14, 2017 · 37 revisions

This document describes how to install adagios from source on debian based systems.

Note: The preferred way is to install adagios via debian packages. only use this guide if you know what you are doing !

Installing adagios

Install nagios3 and mk-livestatus if you don't already have it:

apt-get install nagios3 check-mk-livestatus

Install Dependencies:

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

Pynag package is only available on Debian Sid at the moment. For Debian Squeeze, Wheezy and Jessie, you need install pynag with pip. Install python-pip if needed :

apt-get install python-pip

And install pynag

pip install pynag

Get latest bleeding-edge source from github:

cd /opt/
git clone https://github.com/opinkerfi/adagios.git

Create a configuration directory for adagios and edit paths:

cp -r /opt/adagios/adagios/etc/adagios /etc/
chown -R nagios /etc/adagios/
cd /etc/adagios
sed -i 's|/etc/nagios/nagios.cfg|/etc/nagios3/nagios.cfg|;' adagios.conf
sed -i 's|sudo /etc/init.d/nagios|sudo /etc/init.d/nagios3|;' adagios.conf
sed -i 's|nagios_url = "/nagios"|nagios_url = "/nagios3"|;' adagios.conf

Enable mk-livestatus broker_module and restart nagios to load new configuration:

pynag config --append "broker_module=/usr/lib/check_mk/livestatus.o /var/lib/nagios3/rw/livestatus"
pynag config --append cfg_dir=/etc/adagios
service nagios3 reload

Configure Apache to load Adagios in wsgi:

cat << EOF > /etc/apache2/conf.d/adagios.conf
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 /opt/adagios/adagios/apache/adagios.wsgi

Alias /adagios/media /opt/adagios/adagios/media

<Location /adagios>
   AuthName "Adagios Access"
   AuthType Basic
   AuthUserFile /etc/nagios3/htpasswd.users
   Require valid-user
</Location>
EOF

Create your user, replace adagios with your username and securepassword with a randomly generated, secure password:

htpasswd -b /etc/nagios3/htpasswd.users adagios securepassword

Restart Apache:

service apache2 restart

Open your browser and go to http://127.0.0.1/adagios

Installing okconfig plugin

The okconfig plugin, which is required if you want to use adagios' REST API is installed as follows:

cd /opt
git clone git://github.com/opinkerfi/okconfig.git
cd okconfig
sudo python setup.py install
okconfig init
# Use this to verify installation
okconfig verify

Once installed restart Apache in order to load all the new modules:

service apache2 restart

Open your browser and go to http://127.0.0.1/adagios, you should see a new item named "Okconfig" in the top toolbar.

Final adjustments

Once you've opened your Adagios site, make sure that the binaries and configurations are correct as well. To go about this, head to the top-right area of your Adagios site, next to your Adagios username a white gear will appear, click said gear and then click Settings.

Once inside the Settings pane, replace the following fields for the provided values:

Destination directory: /etc/nagios3/adagios/
Nagios binary: /usr/sbin/nagios3
Pnp filepath: /usr/share/pnp4nagios/html/index.php

Once completed, click save and proceed to create the adagios folder for objects

mkdir /etc/nagios3/adagios
pynag config --append cfg_dir=/etc/nagios3/adagios

And to conclude, restart the Apache server as well as Nagios

service apache2 restart
service nagios3 restart

Install on Debian-based systems (Debian, Ubuntu) for use with Shinken

Introduction

This documentation is based off the ones given on the official Adagios github page and another documentation for debian based systems. Both of them can be found here: https://github.com/opinkerfi/adagios/wiki/Install-guide http://webcache.googleusercontent.com/search?q=cache:r1scUd1hjC8J:blog.benjaminperrin.fr/index.php/2013/07/09/installer-nagios3-et-adagios-sur-debian-7-wheezy/&lr=lang_en|lang_fr&hl=en&tbs=lr:lang_1en|lang_1fr&strip=1

warning

Please note that the okconfig team will not officially support this installation method.

Instructions

Installing The Packages

Install the opensource.is repositories put a line like this into your apt sources If you do not have the file /etc/lsb-release on your system you have to know the codename for your distribution so you can add the right repositories

For example: Ubuntu 12.04 is "precise" and Debian 7 is "wheezy":

source /etc/lsb-release
echo "deb http://opensource.is/repo/debian $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/opensource.is.list
apt-get update

Install pre-requisits:

apt-get install git libapache2-mod-wsgi pynag

Also, make sure you have installed the following packages from the Debian repos (don't forget the dependencies). You can find them here. After downloading them (wget) you can install them with dpkg -i <package1> <package2>...:

shinken
shinken-module-broker-livestatus
shinken-module-broker-livestatus-sqlite

Install adagios:

apt-get install adagios

Change Nagios references in Pynag

Add the Shinken config file location in Pynag. If you wanted to modify the reference to Nagios and change it to a reference to Shinken, is should also work.:

sed -i "s#'/usr/local/icinga/etc/icinga.cfg',#'/usr/local/icinga/etc/icinga.cfg',\n                          '/etc/shinken/shinken.cfg',#g" /usr/local/lib/python2.7/dist-packages/pynag/Parsers/__init__.py

Fix Pynag's reference to mk-livestatus: Shinken has its own livestatus module, no need for mk_livestatus:

sed -i 's#v.find("livestatus.o")#v.find("live")#gw /dev/stdout' /usr/local/lib/python2.7/dist-packages/pynag/Parsers/__init__.py

If you plan on using the built-in status view in Adagios you need these. Shinken does not have two livestatus broker modules and Pynag expects two arguments. (Hackish fix but it works):

pynag config --append "broker_module=/dev/null /var/lib/shinken/rw/live"

warning

Only do the few following instructions if the previous call failed and you have received errors configuration errors : that you believe could be fixed by these commands.

If this failed fix the errors... I was hitting two (these are probably just typos in the configs used in the packages). Fix retention-picklefile.cfg if needed:

echo "}" >> /etc/shinken/shinken-specific/retention-picklefile.cfg

Fix templates.cfg if needed:

sed -i '60s/{/}/w /dev/stdout' /etc/shinken/templates.cfg

Then rerun:

pynag config --append "broker_module=/dev/null /var/lib/shinken/rw/live"

Continue with the "normal" Adagios install

New objects created with Adagios go here, make sure Shinken is reading that directory:

mkdir -p /etc/shinken/adagios
pynag config --append cfg_dir=/etc/shinken/adagios

Create git repo which adagios uses for version control:

cd /etc/shinken/
git init
git add .
git commit -a -m "Initial commit"

Make sure nagios group will always have write access to the configuration files:

chown -R shinken /etc/shinken /etc/shinken

Fix the sudoers file:

cp /opt/adagios/adagios/etc/sudoers.d/adagios /etc/sudoers.d/adagios
sed -e "s#nagios3#shinken#g" -e "s#nagios#shinken#g" -i /etc/sudoers.d/adagios

Add a Django Secret Key (Don't use this one):

sed -i '141s/""/"SOUP3rS3cre7keyBr0"/w /dev/stdout' /usr/lib/python2.7/dist-packages/adagios/settings.py

warning

Make sure you haven't used the same key... you have been warned!

Fix some references:

sed -i 's/\/etc\/nagios\/nagios\.cfg/\/etc\/shinken\/shinken\.cfg/' /etc/adagios/adagios.conf
sed -i 's/\/etc\/nagios\/adagios\//\/etc\/shinken\/adagios\//' /etc/adagios/adagios.conf
sed -i 's/\/etc\/init.d\/nagios/\/etc\/init.d\/shinken-arbiter/' /etc/adagios/adagios.conf
sed -i 's/\/usr\/sbin\/nagios/\/usr\/bin\/shinken-arbiter/' /etc/adagios/adagios.conf

Configure the web server

Fix Apache2 wsgi config:

sed -e 's/nagios/shinken/g' -e 's/Nagios/Shinken/g' -i /etc/apache2/conf.d/adagios.conf

Create htpasswd:

cd /etc/shinken
htpasswd -s -b -c htpasswd.users admin admin

Configure the Livestatus Module

Adagios uses mk_livestatus qhich uses a socket for communications. Shinken by default uses TCP port 50000. The shinken/broker-livestatus.cfg offers the option to change this default.

Use socket instead of TCP port:

sed -i '11s/host/# host/w /dev/stdout' /etc/shinken/shinken-specific/broker-livestatus.cfg
sed -i '12s/port/# port/w /dev/stdout' /etc/shinken/shinken-specific/broker-livestatus.cfg
sed -i '13s/#[\s]*socket/socket/w /dev/stdout' /etc/shinken/shinken-specific/broker-livestatus.cfg

Load Livestatus module:

sed -i '40s/\s*$/, Livestatus/w /dev/stdout' /etc/shinken/shinken-specific/broker.cfg

Configure Adagios' verify command to work with Shinken (Commands to the Shinken arbiter take an extra -c switch):

sed -i "s#\"%s -v '%s'\" % (nagios_binary, nagios_config)#\"%s -v -c '%s'\" % (nagios_binary, nagios_config)#gw /dev/stdout" /usr/share/pyshared/adagios/misc/forms.py

Restart with the new configs

Restart the services:

service apache2 restart && service shinken restart

OkConfig

Install the prerequisites: :

apt-get install python-paramiko

Get the sources: :

cd /opt
git clone git://github.com/opinkerfi/okconfig.git
cd okconfig

Configure OkConfig to work with Shinken:

echo 'PYTHONPATH=$PYTHONPATH:/opt/okconfig' > /etc/profile.d/okconfig.sh
source /etc/profile
mkdir /etc/shinken/okconfig
pynag config --append cfg_dir=/etc/shinken/okconfig
pynag config --append cfg_dir=/usr/share/okconfig/templates

Edit /opt/okconfig/etc/okconfig.conf and replace the Nagios paths by Shinken paths: :

sed -i 's#^nagios_config.*$#nagios_config              /etc/shinken/shinken.cfg#w /dev/stdout' /opt/okconfig/etc/okconfig.conf
sed -i 's#^destination_directory.*$#destination_directory              /etc/shinken/okconfig/#w /dev/stdout' /opt/okconfig/etc/okconfig.conf
sed -i 's#^examples_directory_local.*$#destination_directory_local              /etc/shinken/okconfig/#w /dev/stdout' /opt/okconfig/etc/okconfig.conf

Copy configuration file in /etc :

cp /opt/okconfig/etc/okconfig.conf /etc/okconfig.conf

Run the setup: :

python setup.py install
okconfig init
okconfig verify

Fix the access rights: :

chown -R shinken:shinken  /etc/shinken /etc/okconfig.conf

Restart the services:

service apache2 restart && service shinken restart