Tuesday, October 11, 2016

Setting up Nagios Core 4 on Ubuntu 16.04

Setting up Nagios Core 4 on Ubuntu 16.04

Nagios XI is the Enterprise version of Nagios with lots of features (comes with a price) compared to Nagios Core 4.  There is a free licence for Nagios XI but limited to small environment.

Nagios XI installations with a free license are limited to monitoring seven (7) hosts (nodes). There is no limitation on the number of services that can be monitored with a free license.

Here are the steps based on [1] and [2] references:
Preparation: Install the required packages 
sudo apt-get install apache2 libapache2-mod-php5 build-essential libgd-dev
1) Prepare accounts (user nagios and group nagcmd & nagios) 
sudo -s
/usr/sbin/useradd -m -s /bin/bash nagios
passwd nagios
/usr/sbin/groupadd nagios
/usr/sbin/usermod -G nagios nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data

2) Download source codes
mkdir ~/downloads
cd ~/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.1.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz#_ga=1.209680983.439473619.1475788765
(The one in the Ubuntu Quickstart is outdated) 
3) Untar, Compile and install
cd ~/downloads
tar xzf nagios-4.2.1.tar.gz
cd nagios-4.2.1
./configure --with-command-group=nagcmd

make all
make install
make install-init
make install-config
make install-commandmode
4) Customise email address and other configurations
vi /usr/local/nagios/etc/objects/contacts.cfg 

5) Configure the web interface
make install-webconf (Makefile was somehow not updated for Ubuntu from RedHat for this option)
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/etc/init.d/apache2 reload
6) Compile and install the plug-ins
cd ~/downloads
tar xzf nagios-plugins-2.1.2.tar.gz 
cd nagios-plugins-2.1.2/
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl 
make install
7) Configure startup and start Nagios
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
8) Login to Web Interface

[1] https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-ubuntu.html
[2] https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04
[3] https://assets.nagios.com/handouts/nagiosxi/Nagios-XI-vs-Nagios-Core-Feature-Comparison.pdf

No comments: