-
Notifications
You must be signed in to change notification settings - Fork 74
Naemon and Adagios Install Guide
hakong edited this page Apr 9, 2019
·
57 revisions
This document explains how to install Adagios and Naemon on CentOS 7 or Red Hat Enterprise Linux 7 x86_64.
If you find any errors in these docs, please be so kind to either update the wiki or file an issue in the issue tracker.
# If you don't know how to configure SElinux, put it in permissive mode:
sed -i "s/SELINUX=enforcing/SELINUX=permissive/" /etc/selinux/config
setenforce 0
# First install the opensource.is and consol labs repositories
rpm -ihv http://opensource.is/repo/ok-release.rpm
rpm -Uvh https://labs.consol.de/repo/stable/rhel7/x86_64/labs-consol-stable.rhel7.noarch.rpm
yum update -y ok-release
# Centos users need to install the epel repositories (fedora users skip this step)
yum install -y epel-release
# Redhat users:
subscription-manager repos --enable=rhel-7-server-optional-rpms
subscription-manager repos --enable=rhel-7-server-extras-rpms
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Install Naemon / Thruk
yum install -y naemon
# Install Adagios and other needed packages
yum --enablerepo=ok-testing install -y python2-django16 adagios okconfig git acl pnp4nagios python-setuptools
# Now all the packages have been installed, and we need to do a little bit of
# configuration before we start doing awesome monitoring
# Lets make sure adagios can write to naemon configuration files, and that
# it is a valid git repo so we have audit trail
cd /etc/naemon/
git init
git config user.name "User"
git config user.email "email@mail.com"
git add .
git commit -a -m "Initial commit"
# Fix permissions for naemon and pnp4nagios
chgrp naemon /etc/pnp4nagios/process_perfdata.cfg
chown naemon:naemon -R /etc/adagios
chown naemon:naemon /var/lib/adagios /var/lib/pnp4nagios /var/spool/pnp4nagios
chown -R naemon:root /var/log/okconfig /var/log/pnp4nagios
setfacl -R -m group:naemon:rwx -m d:group:naemon:rwx /etc/naemon/ /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/spool/pnp4nagios
setfacl -R -m user:naemon:rwx -m d:user:naemon:rwx /var/log/okconfig /var/log/pnp4nagios
# Make sure nagios doesn't interfere
mkdir /etc/nagios/disabled
mv /etc/nagios/{nagios,cgi}.cfg /etc/nagios/disabled/
# Make objects created by adagios go to /etc/naemon/adagios
mkdir -p /etc/naemon/adagios
pynag config --append cfg_dir=/etc/naemon/adagios
# Make adagios naemon aware
sed -i '
s|/etc/nagios/passwd|/etc/thruk/htpasswd|g
s|user=nagios|user=naemon|g
s|group=nagios|group=naemon|g' /etc/httpd/conf.d/adagios.conf
sed -i '
s|/etc/nagios/nagios.cfg|/etc/naemon/naemon.cfg|g
s|nagios_url = "/nagios|nagios_url = "/thruk|g
s|/etc/nagios/adagios/|/etc/naemon/adagios/|g
s|/etc/init.d/nagios|/etc/init.d/naemon|g
s|nagios_service = "nagios"|nagios_service = "naemon"|g
s|livestatus_path = None|livestatus_path = "/var/cache/naemon/live"|g
s|/usr/sbin/nagios|/usr/bin/naemon|g' /etc/adagios/adagios.conf
# Make okconfig naemon aware
sed -i '
s|/etc/nagios/nagios.cfg|/etc/naemon/naemon.cfg|g
s|/etc/nagios/okconfig/|/etc/naemon/okconfig/|g
s|/etc/nagios/okconfig/examples|/etc/naemon/okconfig/examples|g' /etc/okconfig.conf
okconfig init
okconfig verify
# Add naemon to apache group so it has permissions to pnp4nagios's session files
usermod -G apache naemon
# Allow Adagios to control the service
sed -i '
s|nagios|naemon|g
s|/usr/sbin/naemon|/usr/bin/naemon|g' /etc/sudoers.d/adagios
# A list of strings representing the host/domain names that this Django site can
# serve. This is a security measure to prevent HTTP Host header attacks
echo "ALLOWED_HOSTS = ['*']" >> /etc/adagios/adagios.conf
# Make naemon use nagios plugins, more people are doing it like that.
sed -i 's|/usr/lib64/naemon/plugins|/usr/lib64/nagios/plugins|g' /etc/naemon/resource.cfg
# Configure pnp4nagios
sed -i 's|/etc/nagios/passwd|/etc/thruk/htpasswd|g' /etc/httpd/conf.d/pnp4nagios.conf
sed -i '
s/user = nagios/user = naemon/g
s/group = nagios/group = naemon/g' /etc/pnp4nagios/npcd.cfg
# Enable Naemon performance data
pynag config --set "process_performance_data=1"
# service performance data
pynag config --set 'service_perfdata_file=/var/lib/naemon/service-perfdata'
pynag config --set 'service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$'
pynag config --set 'service_perfdata_file_mode=a'
pynag config --set 'service_perfdata_file_processing_interval=15'
pynag config --set 'service_perfdata_file_processing_command=process-service-perfdata-file'
# host performance data
pynag config --set 'host_perfdata_file=/var/lib/naemon/host-perfdata'
pynag config --set 'host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$'
pynag config --set 'host_perfdata_file_mode=a'
pynag config --set 'host_perfdata_file_processing_interval=15'
pynag config --set 'host_perfdata_file_processing_command=process-host-perfdata-file'
pynag add command command_name=process-service-perfdata-file command_line='/bin/mv /var/lib/naemon/service-perfdata /var/spool/pnp4nagios/service-perfdata.$TIMET$'
pynag add command command_name=process-host-perfdata-file command_line='/bin/mv /var/lib/naemon/host-perfdata /var/spool/pnp4nagios/host-perfdata.$TIMET$'
pynag config --append cfg_dir=/etc/naemon/commands/
# Reset password for Thruk/Naemon admin user
htpasswd -c /etc/thruk/htpasswd thrukadmin
# Disable OMD thruk service
systemctl disable thruk.service
# We need to restart both apache and naemon so new changes take effect
systemctl enable naemon httpd npcd
systemctl restart naemon httpd npcd
# Allow connections through the firewall on port 80 and 443
firewall-cmd --add-service=https --permanent
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
# Install nagios plugins
yum install -y nagios-plugins-all
# Install nagios plugins from Opin Kerfi (nagios-okplugin)
yum install -y nagios-okplugin-* --skip-broken