Skip to content

Install Guide on Raspian Wheezy (Raspberry Pi)

jlaxdal edited this page Jul 17, 2017 · 4 revisions

Adagios on Raspbian Wheezy 7.11 (Raspberry Pi)

Make sure your system is fully updated

apt-get update
apt-get upgrade

Install pre-requisites
Select a password for the nagios user when prompted

apt-get -y install nagios3 check-mk-livestatus

(optional) Install NRPE if you want it
Changes by OpenSSL have made some problems for the nrpe client and servers. The NRPE team have made some changes to remedy it but it requires the newest version which afaik isn't on the system repos yet, so we must get it straight from the source.
https://github.com/NagiosEnterprises/nrpe/issues/113
Commit used 5a517649580f05533e47cdfb77167b2fb5e9e848

apt-get install -y automake autotools-dev libmcrypt4 m4  

if you are installing nrpe from source on clients we also need gcc libssl-dev make

cd
git clone https://github.com/NagiosEnterprises/nrpe.git
cd nrpe/
autoconf
./configure --enable-command-args
make all
make install-groups-users
make install
make install-config
make install-init
update-rc.d nrpe start 2 3 4 5 stop 0 1 6  

the update-rc.d is for the raspian, you'd want systemctl enable nrpe or other commands on other systems

Install dependencies

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

Install Pip

cd
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

Install Pynag
Neither Pynag in the Raspbian repo nor Pynag from Pip work correctly, so we get it from the source
Pynag used in this guide was commit 9bcf9ed60d249e7212a49af3de2099e7fb9a2352

cd
mkdir pynag
cd pynag
git clone https://github.com/pynag/pynag.git
cd pynag/
python setup.py build
python setup.py install

The path to nagios is wrong in the Pynag package which messes up the Daemon detection method so we need to change them

sed -i 's|nagios_bin="/usr/bin/nagios"|nagios_bin="/usr/bin/nagios3"|;' /usr/local/lib/python2.7/dist-packages/pynag/Control/__init__.py
sed -i 's|nagios_cfg="/etc/nagios/nagios.cfg"|nagios_cfg="/etc/nagios2/nagios.cfg"|;' /usr/local/lib/python2.7/dist-packages/pynag/Control/__init__.py
sed -i 's|service_name="nagios"|service_name="nagios3"|;' /usr/local/lib/python2.7/dist-packages/pynag/Control/__init__.py

Install Django 1.6.11
Latest version of Django does not seem to work correctly so we explicitly install Django 1.6.11

cd
mkdir django
cd django
wget https://www.djangoproject.com/m/releases/1.6/Django-1.6.11.tar.gz
tar -xzf Django-1.6.11.tar.gz
cd Django-1.6.11/
python setup.py install

Install Python requirements
First we install the build requirements if needed and then we install the python wheel and latest Paramiko which will take quite a while to complete

apt-get -y install python-dev libffi-dev
pip install setuptools wheel --upgrade 
pip install paramiko --upgrade

Install Adagios
The commit used for this guide was 155b9731383f55eca889c98d0cedbab1df30a87c

cd /opt/
git clone https://github.com/opinkerfi/adagios.git
cp -r /opt/adagios/adagios/etc/adagios /etc/
cd /etc/adagios

Update paths in the config file

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 = "/adagios"|;' adagios.conf
mkdir /etc/nagios3/adagios
sed -i 's|destination_directory = "/etc/nagios/adagios/"|destination_directory = "/etc/nagios3/adagios/"|;'     adagios.conf
sed -i 's|pnp_filepath="/usr/share/nagios/html/pnp4nagios/index.php"|pnp_filepath="/usr/share/pnp4nagios/html/index.php"|;' adagios.conf
sed -i 's|/var/lib/adagios/contrib/|/opt/adagios/adagios/contrib|;' adagios.conf
sed -i 's|nagios_binary="/usr/sbin/nagios"|nagios_binary="/usr/sbin/nagios3"|;' adagios.conf
sed -i 's|nagios_service = "nagios"|nagios_service = "nagios3"|;' adagios.conf
chown -R nagios /etc/adagios/
chown -R nagios /etc/nagios3/

Add new settings to the nagios.conf file with Pynag and create a working directory for Adagios in var/lib

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

configure Apache

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/wsgi.py

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

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

Add a user that can access the Adagios, default username for the first admin is 'adagios'. Change the password to something you want

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

Add nagios to the sudoers file

cat << EOT > /etc/sudoers.d/nagios-adagios
nagios ALL=(root) NOPASSWD: ALL
EOT
chmod 0440 /etc/sudoers.d/nagios-adagios

After restarting everything you can go to http://your server ip here/adagios to test if everything is working properly

service nagios3 restart
service apache2 restart

Installing okconfig
The commit used in this guide was 3e9ee0419873016d647b99992f1ea85dfe3530f9

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

We need to make some changes to the okconfig config file, I advice also checking the /etc/okconfig.conf file manually and verify if all the paths are correct after executing the following commands

echo 'export PYTHONPATH=$PYTHONPATH:/opt/okconfig' > /etc/profile.d/okconfig.sh
cp /opt/okconfig/etc/okconfig.conf /etc/okconfig.conf
source /etc/profile
ln -s /opt/okconfig/usr/share/okconfig /usr/share/
ln -s /opt/okconfig/usr/bin/okconfig /usr/local/bin/
sed -i 's|/etc/nagios/|/etc/nagios3/|;' /etc/okconfig.conf
pynag config --append cfg_dir=/etc/nagios3/okconfig

Test the config file and install okconfig if there are no errors

okconfig init
okconfig verify
python setup.py install
chown nagios /etc/nagios3/okconfig/

Adagios integrates a git repo handler that stores any configuration changes made in a git repo.
If you do not want this feature you can disable it by going to Gear->Settings->Enable Githandler

cd /etc/nagios3/
git init
git config user.name "yourname"
git config user.email "[email protected]"
git add *
git commit -m "Initial commit"
chown -R nagios /etc/nagios3/* /etc/nagios3/.git

Restart everything

service nagios3 restart
service apache2 restart

And there you have it, Adagios installed.