Created
May 13, 2016 15:10
-
-
Save gardart/f0576610818a6d6ddc36147f9ea9c8db to your computer and use it in GitHub Desktop.
install naemon thruk adagios on RHEL7
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
yum update -y | |
yum install -y epel-release | |
yum update -y | |
yum clean all | |
# Add repos | |
rpm -Uvh "https://labs.consol.de/repo/stable/rhel7/i386/labs-consol-stable.rhel7.noarch.rpm" | |
rpm -ihv http://opensource.is/repo/ok-release.rpm | |
yum update -y ok-release | |
######################### | |
# Install Deps # | |
######################### | |
yum install -y git acl | |
######################### | |
# Install Naemon # | |
######################### | |
# Naemon | |
yum install -y naemon | |
# Adagios and other needed packages | |
yum --enablerepo=ok-testing install -y adagios okconfig python-setuptools | |
# Install plugins | |
#yum install -y nagios-plugins-all | |
######################### | |
# Install Adagios # | |
######################### | |
yum install -y python-setuptools | |
yum --enablerepo=ok-testing install -y adagios okconfig pnp4nagios | |
## | |
# Workaround until OK update their repo | |
#rpm -Uvh https://github.com/opinkerfi/adagios/releases/download/adagios-1.6.3-1/adagios-1.6.3-1.el7.centos.noarch.rpm | |
#wget https://raw.githubusercontent.com/opinkerfi/okconfig/master/usr/share/okconfig/client/linux/install_okagent.sh -O /usr/share/okconfig/client/linux/install_okagent.sh | |
#chmod +x /usr/share/okconfig/client/linux/install_okagent.sh | |
## | |
# Lets make sure adagios can write to nagios configuration files, and that | |
# it is a valid git repo so we have audit trail | |
cd /etc/naemon | |
git init /etc/naemon | |
git config user.name "User" | |
git config user.email "[email protected]" | |
git add * | |
git commit -m "Initial commit" | |
# Fix permissions for naemon and pnp4nagios | |
chown -R naemon:naemon /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg | |
# ACL group permissions need g+rwx | |
chmod g+rwx -R /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg | |
setfacl -R -m group:naemon:rwx -m d:group:naemon:rwx /etc/naemon/ /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg | |
# 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/naemon/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 = "/naemon|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 | |
# 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 | |
# 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/naemon/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/ | |
# We need to restart both apache and naemon so new changes take effect | |
systemctl enable naemon | |
systemctl enable httpd | |
systemctl enable npcd | |
systemctl restart naemon | |
systemctl restart httpd | |
systemctl restart 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 | |
### | |
# Configure Remote Livestatus | |
sed -i 's|devel|nagios|g' /etc/xinetd.d/livestatus | |
sed -i 's|/omd/sites/nagios/bin/unixcat|/usr/bin/unixcat|g' /etc/xinetd.d/livestatus | |
sed -i 's|/omd/sites/nagios/tmp/run/live|/var/spool/nagios/cmd/livestatus|g' /etc/xinetd.d/livestatus | |
firewall-cmd --permanent --add-port=6557/tcp # Livestatus port | |
firewall-cmd --reload | |
service xinetd restart ; chkconfig xinetd on | |
# Configure Backends | |
cat >>/etc/thruk/thruk_local.conf << EOF | |
<Component Thruk::Backend> | |
<peer> | |
name = $HOSTNAME | |
type = livestatus | |
<options> | |
peer = localhost:6557 | |
</options> | |
</peer> | |
</Component> | |
EOF | |
rm -f /etc/thruk/htpasswd | |
ln -s /etc/nagios/passwd /etc/thruk/htpasswd | |
sed -i 's|thrukadmin|thrukadmin,nagiosadmin|g' /etc/thruk/cgi.cfg | |
service httpd reload | |
service xinetd restart | |
service nagios restart | |
service thruk restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment