Skip to content

Instantly share code, notes, and snippets.

@gardart
Last active February 3, 2016 11:20
Show Gist options
  • Save gardart/1c83c9df4d5ed2023f0e to your computer and use it in GitHub Desktop.
Save gardart/1c83c9df4d5ed2023f0e to your computer and use it in GitHub Desktop.
install-nagios-thruk-adagios-RHEL6.txt
yum update -y
yum install -y epel-release
yum clean all
# Add repos
rpm -Uvh "https://labs.consol.de/repo/stable/rhel6/i386/labs-consol-stable.rhel6.noarch.rpm"
rpm -ihv http://opensource.is/repo/ok-release.rpm
yum update -y ok-release
#########################
# Install Deps #
#########################
yum install -y git acl
#########################
# Install Nagios #
#########################
# Nagios 3.5.1
yum install -y nagios
# Install plugins
yum install -y nagios-plugins-all
# Install livestatus
yum install -y xinetd
yum install -y mk-livestatus
#yum --enablerepo=ok-testing install -y mk-livestatus
#########################
# Install Thruk #
#########################
yum install -y thruk
mv /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf.inactive
#########################
# Install Adagios #
#########################
yum install -y python-setuptools
yum --enablerepo=ok-testing install -y adagios okconfig pnp4nagios
# OKplugins
#yum install -y nagios-okplugin-apc nagios-okplugin-check_time nagios-okplugin-check_disks nagios-okplugin-brocade nagios-okplugin-mailblacklist nagios-okplugin-crit2warn
yum install -y nagios-okplugin-check_uptime
# 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/nagios
git init /etc/nagios/
git config user.name "User"
git config user.email "email@mail.com"
git add *
git commit -m "Initial commit"
# Make sure nagios group will always have write access to the configuration files:
chown -R nagios /etc/nagios/* /etc/nagios/.git
setfacl -R -m group:nagios:rwx /etc/nagios/
setfacl -R -m d:group:nagios:rwx /etc/nagios/
# By default objects created by adagios will go to /etc/nagios/adagios so make sure that this directory exists and nagios.cfg contains a reference to this directory.
mkdir -p /etc/nagios/adagios
pynag config --append cfg_dir=/etc/nagios/adagios
# The status view relies on broker modules livestatus and pnp4nagios, so lets configure
# nagios.cfg to use those
pynag config --append "broker_module=/usr/lib64/nagios/brokers/npcdmod.o config_file=/etc/pnp4nagios/npcd.cfg"
pynag config --append "broker_module=/usr/lib64/mk-livestatus/livestatus.o /var/spool/nagios/cmd/livestatus"
pynag config --set "process_performance_data=1"
# Add nagios to apache group so it has permissions to pnp4nagios's session files
usermod -G apache nagios
# We need to allow user nagios to restart nagios daemon
echo -e '\nDefaults:nagios !requiretty' >> /etc/sudoers
echo -e '\nnagios ALL = (root) NOPASSWD: /etc/init.d/nagios' >> /etc/sudoers
##############
# Firewall #
##############
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
# Start
# We need to restart both apache and nagios so new changes take effect
service nagios start ; chkconfig nagios on
service httpd start ; chkconfig httpd on
service npcd start ; chkconfig npcd on
# 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
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 = 127.0.0.1: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 restart
service xinetd restart
service nagios restart
service thruk restart
service npcd restart
######################
# Configure SELINUX #
######################
# THRUK
chcon -t httpd_sys_script_exec_t /usr/share/thruk/fcgid_env.sh
chcon -t httpd_sys_script_exec_t /usr/share/thruk/script/thruk_fastcgi.pl
chcon -R -t httpd_sys_content_rw_t /var/lib/thruk/
chcon -R -t httpd_sys_content_rw_t /var/cache/thruk/
chcon -R -t httpd_log_t /var/log/thruk/
setsebool -P httpd_can_network_connect on
# Adagios
chcon -R -t httpd_sys_content_rw_t /etc/nagios/okconfig
chcon -R -t httpd_sys_content_rw_t /etc/nagios/adagios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment