Last active
January 29, 2016 22:11
-
-
Save addiedx44/21dd873498327372235e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$EUID" -ne 0 ] ; then | |
echo "Please run this installer as root (sudo -Hs)" | |
exit | |
fi | |
set +x | |
function step() { | |
echo "$@" "($((++n)) of 8)" | |
} | |
step 'Installing prereqs...' | |
{ | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get update | |
apt-get -y install curl nagios3 git libapache2-mod-wsgi check-mk-livestatus check-postgres | |
python - < <(curl -sL https://bootstrap.pypa.io/get-pip.py) | |
} &> /dev/null | |
step 'Installing adagios...' | |
{ | |
pip install django==1.5 pynag adagios simplejson | |
} &> /dev/null | |
step 'Installing pnp4nagios (graphs)...' | |
{ | |
apt-get -y install pnp4nagios | |
pynag config --set "process_performance_data=1" | |
pynag config --append "broker_module=/usr/lib/pnp4nagios/npcdmod.o config_file=/etc/pnp4nagios/npcd.cfg" | |
usermod -G www-data nagios | |
sed -i 's/RUN.*/RUN="yes"/' /etc/default/npcd | |
} &> /dev/null | |
step 'Installing additional plugins...' | |
{ | |
cd /usr/lib/nagios/plugins | |
wget 'https://github.com/orthecreedence/check_elasticsearch/blob/master/check_elasticsearch' | |
chmod a+x check_elasticsearch | |
} &> /dev/null | |
step 'Setting privileges...' | |
{ | |
cat > /etc/sudoers.d/nagios <<EOF | |
Cmnd_Alias NAGIOS_CMDS = /etc/init.d/nagios3 status, /etc/init.d/nagios3 stop, /etc/init.d/nagios3 start, /etc/init.d/nagios3 restart, /etc/init.d/nagios3 reload | |
nagios ALL = NOPASSWD: NAGIOS_CMDS | |
EOF | |
} &> /dev/null | |
step 'Configuring nagios/adagios...' | |
{ | |
pynag config --append "broker_module=/usr/lib/check_mk/livestatus.o /var/lib/nagios3/rw/livestatus" | |
mkdir -p /var/lib/adagios/userdata | |
mkdir -p /etc/nagios3/adagios | |
pynag config --append cfg_dir=/etc/nagios3/adagios | |
cd /etc/nagios3/ | |
git init | |
git config user.name nagios | |
git config user.email nagios@localhost | |
git add . | |
git commit -a -m "Initial commit" | |
htpasswd -bc /etc/nagios3/htpasswd.users adagios adagios | |
cd /etc/adagios | |
sed -i -e 's|/etc/nagios/nagios.cfg|/etc/nagios3/nagios.cfg|' \ | |
-e 's|sudo /etc/init.d/nagios|sudo /etc/init.d/nagios3|' \ | |
-e 's|nagios_url = "/nagios"|nagios_url = "/nagios3"|' \ | |
-e 's|nagios_binary="/usr/sbin/nagios"|nagios_binary="/usr/sbin/nagios3"|' \ | |
-e 's|destination_directory = "/etc/nagios/adagios/"|destination_directory = "/etc/nagios3/adagios/"|' \ | |
adagios.conf | |
chown -R nagios /usr/lib/nagios /etc/nagios3 /etc/adagios /var/lib/adagios | |
} &> /dev/null | |
step 'Configuring apache...' | |
{ | |
cat > /etc/apache2/conf-available/adagios.conf <<EOF | |
WSGISocketPrefix /var/run/apache2/wsgi | |
WSGIDaemonProcess adagios user=nagios group=nagios processes=1 threads=25 python-path=/usr/local/lib/python2.7/dist-packages/adagios:/usr/local/lib/python2.7/dist-packages/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 | |
<Location /adagios> | |
AuthName "Adagios Access" | |
AuthType Basic | |
AuthUserFile /etc/nagios3/htpasswd.users | |
Require valid-user | |
</Location> | |
EOF | |
a2enconf adagios.conf | |
} &> /dev/null | |
step 'Restarting services...' | |
{ | |
service npcd restart | |
service nagios3 restart | |
service apache2 restart | |
} &> /dev/null | |
echo | |
echo | |
echo "Adagios is now installed! Please visit http://$(hostname -f)/adagios" | |
echo "and log in with adagios/adagios. If you have trouble, check the hostname" | |
echo "and that Apache is listening on the correct port." | |
echo | |
echo "You can add/modify users with:" | |
echo | |
echo " htpasswd /etc/nagios3/htpasswd.users username" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment