Skip to content

Instantly share code, notes, and snippets.

@gardart
Last active June 10, 2022 13:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gardart/f09638ef0be7853c8284 to your computer and use it in GitHub Desktop.
Save gardart/f09638ef0be7853c8284 to your computer and use it in GitHub Desktop.
Install Nagios / Thruk / Adagios - RHEL7
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
yum install libstdc++-static
#########################
# Install Nagios #
#########################
# Nagios 3.5.1
#yum localinstall ftp://ftp.is.co.za/mirror/fedora.redhat.com/epel/beta/7/x86_64/nagios-3.5.1-1.el7.x86_64.rpm
# Nagios 4
yum install -y nagios
# Install plugins
yum install -y nagios-plugins-all
#########################
# Install Livestatus #
#########################
yum install -y xinetd
cd /tmp
wget https://mathias-kettner.de/download/mk-livestatus-1.2.8p2.tar.gz
tar xvfz mk-livestatus-1.2.8p2.tar.gz
cd mk-livestatus-1.2.8p2
./configure --with-nagios4
make -j 8
make install
ls /usr/local/lib/mk-livestatus
ln -s /usr/local/bin/unixcat /usr/bin/unixcat
#########################
# 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
#yum localinstall http://opensource.ok.is/repo/testing/rhel6/x86_64/nagios-okplugin-check_uptime-1.0.1-1.git.0.ebe1e3b.el6.x86_64.rpm
# 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/local/lib/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 restart ; chkconfig nagios on
service httpd restart ; chkconfig httpd on
service npcd restart ; chkconfig npcd on
# Configure Remote Livestatus
cat >/etc/xinetd.d/livestatus << EOF
service livestatus
{
type = UNLISTED
socket_type = stream
protocol = tcp
wait = no
# limit to 100 connections per second. Disable 3 secs if above.
cps = 1000 3
# set the number of maximum allowed parallel instances of unixcat.
instances = 500
# limit the maximum number of simultaneous connections from
# one source IP address
per_source = 500
# Disable TCP delay, makes connection more responsive
flags = NODELAY
# Disable this services
disable = no
# TCP port number.
port = 6557
# Paths and users.
user = nagios
server = /usr/bin/unixcat
server_args = /var/spool/nagios/cmd/livestatus
}
EOF
#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
@chamrong007
Copy link

Hello Guide!

I can't login thrukadmin

how to reset it ?

@fitoiia
Copy link

fitoiia commented Apr 26, 2018

hello friend, I have the following problem:

Module '/usr/lib64/nagios/brokers/npcdmod.o' is using an old or unspecified version of the event broker API. Module will be unloaded.

Failed to load module '/usr/lib64/nagios/brokers/npcdmod.o'.

Module loading failed. Aborting.

And Nagios is not running :/

@gardart
Copy link
Author

gardart commented May 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment