Skip to content

Instantly share code, notes, and snippets.

@gardart
Created October 7, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gardart/8850fb9ad3b990ac53ce252d26f33dfe to your computer and use it in GitHub Desktop.
Save gardart/8850fb9ad3b990ac53ce252d26f33dfe to your computer and use it in GitHub Desktop.
install-nagios4-thruk-adagios-RHEL7.txt
yum update -y
yum install -y epel-release
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 libstdc++-static python-setuptools pynag
#
# Install Nagios 4
#
yum install -y nagios nagios-plugins-all
#
# Install Livestatus
#
yum install -y check-mk-livestatus
#
# Install Thruk
#
yum install -y thruk
#
# Install Adagios and OKconfig
#
yum --enablerepo=ok-testing install -y adagios okconfig pynag
#
# Configure Adagios
#
# 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
git config user.name "yourname"
git config user.email "yourname@yourdomain.com"
git add *
git commit -m "Initial commit"
# 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
pynag config --append cfg_dir=/etc/nagios/commands
# Make sure nagios group will always have write access to the configuration files:
chown -R nagios:nagios /etc/nagios/* /etc/nagios/.git
# Add check_mk livestatus broker module to nagios config
pynag config --append "broker_module=/usr/lib64/check_mk/livestatus.o /var/spool/nagios/cmd/livestatus"
echo "ALLOWED_HOSTS = ['*']" >> /etc/adagios/adagios.conf
#
# Configure PNP4Nagios
#
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
# service performance data
pynag config --set 'service_perfdata_file=/var/log/pnp4nagios/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'
# Add process perfdata commands
pynag add command command_name=process-service-perfdata-file command_line='/bin/mv /var/log/pnp4nagios/service-perfdata /var/spool/pnp4nagios/service-perfdata.$TIMET$'
pynag add command command_name=process-host-perfdata-file command_line='/bin/mv /var/log/pnp4nagios/host-perfdata /var/spool/pnp4nagios/host-perfdata.$TIMET$'
#
# Clean up
#
# Disable check_mk templates
mkdir -p /etc/nagios/disabled
mv /etc/nagios/conf.d/check_mk_templates.cfg /etc/nagios/disabled
#
# Enable and start services
#
systemctl restart nagios; systemctl enable nagios
systemctl restart npcd; systemctl enable npcd
systemctl restart httpd; systemctl enable httpd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment