Centos 7 Installation Guide

This page details how to install nagrestonf on Centos 7.

Packages that nagrestconf depends on, such as Nagios and Apache, will be installed automatically.

Before installation

The instructions on this page are for installing nagrestconf and its requirements on a new server.

It is not recommended to follow these instructions on an existing server that is already being used. It might break other applications on the server since packages might be upgraded.

Overview

Installation consists of the following steps:

  • Install using the RPM packages.
  • Configure the Operating System.
  • Test nagrestconf and nagios.
  • Create an initial configuration.
  • Add Plugins.

Run all the commands on this page as the root user, so, for example, run 'sudo su -' before running any other commands.

Install using the RPM packages.

Get the RPM packages for Centos 7 from the download page then copy them to the server.

Alternatively, log onto the server and use wget to get the files directly. Copy and paste the following one-liner to download directly:

for i in nagrestconf-1.174.6-1.noarch.rpm nagrestconf-backup-plugin-1.174.6-1.noarch.rpm nagrestconf-hosts-bulktools-plugin-1.174.6-1.noarch.rpm nagrestconf-services-bulktools-plugin-1.174.6-1.noarch.rpm nagrestconf-services-tab-plugin-1.174.6-1.noarch.rpm; do wget -O $i https://sourceforge.net/projects/nagrestconf/files/Centos/Centos%207/latest/$i/download; done

Open a terminal window or ssh session then add the EPEL repository to satisfy dependencies later on.

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Open a terminal window or ssh session then install nagrestconf and all plugins:

yum --nogpg install nagrestconf-1.174.6-1.noarch.rpm \
    nagrestconf-services-tab-plugin-1.174.6-1.noarch.rpm \
    nagrestconf-services-bulktools-plugin-1.174.6-1.noarch.rpm \
    nagrestconf-hosts-bulktools-plugin-1.174.6-1.noarch.rpm \
    nagrestconf-backup-plugin-1.174.6-1.noarch.rpm

Configure the Operating System

Ensure selinux is disabled, instructions here.

Use the two helper scripts 'nagrestconf_install' and 'slc_configure'.

nagrestconf_install -a
slc_configure --folder=local

Supply a wrapper script for init.d since Centos 7 uses systemd. This is a temporary fix.

[[ ! -e /etc/init.d/nagios ]] && { echo -e '#!/bin/bash\nsystemctl -o verbose $1 nagios.service' >/etc/init.d/nagios; chmod +x /etc/init.d/nagios; }

To enable automatic restart, the cron job needs to be modified to enter the Apache namespace. This is a temporary fix.

# Save list of cron jobs with the restarter filtered out
crontab -l | grep -v "nsenter.*nagios_centos" >newcron

# Add a new cron job to the list
echo '* * * * * /usr/bin/nsenter -t $(ps ax -o ppid,comm,pid | sed -n "s/^ *1 *httpd *\([0-9]*\)/\1/p") -m /usr/bin/restart_nagios_centos7' >>newcron

# Replace the crontab with newcron
crontab newcron
rm newcron

# Create the restarter
cat >/usr/bin/restart_nagios_centos7 <<EnD
/usr/bin/test -e /tmp/nagios_restart_request && ( /bin/rm /tmp/nagios_restart_request; /usr/bin/restart_nagios; )
EnD

# Ensure it's executable
chmod +x /usr/bin/restart_nagios_centos7

Create a password for nagiosadmin - for GUI access to nagios.

htpasswd -bc /etc/nagios/passwd nagiosadmin a_password

Create a password for nagrestconfadmin - for GUI access to nagrestconf.

htpasswd -bc /etc/nagios/nagrestconf.users nagrestconfadmin a_password

Ensure the nagios Query Handler Interface directory is created.

mkdir /var/log/nagios/rw
chown nagios:nagios /var/log/nagios/rw

Note that, by default, the nagrestconf GUI can only be reached from the host it was installed on, localhost. To enable connecting to nagrestconf from other hosts edit the Apache configuration.

For example,

Edit /etc/httpd/conf.d/nagios.conf:

cp /etc/httpd/conf.d/nagios.conf /tmp
sed -i 's#AuthUserFile .*#AuthUserFile /etc/nagios/passwd#i' \
    /etc/httpd/conf.d/nagios.conf

Edit /etc/httpd/conf.d/nagrestconf.conf:

cp /etc/httpd/conf.d/nagrestconf.conf /tmp
sed -i 's#AuthUserFile .*#AuthUserFile /etc/nagios/nagrestconf.users#i' \
    /etc/httpd/conf.d/nagrestconf.conf
sed -i 's/allow from 127.0.0.1/allow from all/i' \
    /etc/httpd/conf.d/nagrestconf.conf
sed -i 's/#Require/Require/i'     /etc/httpd/conf.d/nagrestconf.conf
sed -i 's/#Auth/Auth/i'     /etc/httpd/conf.d/nagrestconf.conf

Restart Apache

service httpd restart

Test nagrestconf and nagios

The nagrestsconf and nagios web interfaces should be accessible now.

Log into nagrestconf with user 'nagrestconfadmin', and the password that was set above.

The nagrestconf interface, at 'http://server/nagrestconf', will look like the following screen shot.

Log into nagios with user 'nagiosadmin', and the password that was set above.

The nagios interface, at 'http://server/nagios', will look like the following screen shot.

Create an initial configuration

To create a simple test configuration use a script that makes REST calls, or use the 'Backup/Restore' button in the nagrestconf GUI. The latter method will be used in this guide.

Create an initial configuration using 'Backup/Restore'

An example configuration can be downloaded from this link, then log into nagrestconf and use the 'Backup/Restore' button.

Click 'Close' in the 'Backup/Restore' dialog then refresh the page.

The new configuration will not appear in the Nagios Web interface until the 'Apply Changes' button is clicked, and then applied.

Add Plugins

Nagios and Nagrestconf should be installed and working, however, the plugins are probably not installed so Nagios will show errors trying to run the host and service checks.

Install the plugins your distribution provides.

Choose the required plugins or install them all as below.

yum install nagios-plugins-all nagios-plugins-nrpe

That's it!

comments powered by Disqus