Install Nagios Core 4.1.1 in Debian Jessie Part 1

About Nagios

Nagios is an enterprise class, open source software that can be used for network and infrastructure monitoring. Using Nagios, we can monitor servers, switches, applications and services etc. It alerts the System Administrator when something goes wrong and also alerts back when the issues have been rectified.

Features

Using Nagios, you can:

  • Monitor your entire IT infrastructure.
  • Identify problems before they occur.
  • Know immediately when problems arise.
  • Share availability data with stakeholders.
  • Detect security breaches.
  • Plan and budget for IT upgrades.
  • Reduce downtime and business losses.

Prerequisites

Make sure your server have installed with fully working LAMP stack. If not, follow the below link to install LAMP server.

Then install the following prerequisites:

apt-get install build-essential libgd2-xpm-dev apache2-utils unzip curl
a2enmod rewrite
a2enmod cgi

Create Nagios User And Group

Create a new nagios user account:

useradd -m nagios
passwd nagios

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data

Download necessary software

Go to the nagios download page, and get the latest version. As of writing this, the latest version was 4.1.1.

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz -O /usr/src/nagios-4.1.1.tar.gz

Download nagios plugins too. Nagios plugins allow you to monitor hosts, devices, services, protocols, and applications with Nagios

wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz -O /usr/src/nagios-plugins-2.1.1.tar.gz

Install Nagios And Plugins

Install nagios

Go to the folder where you’ve downloaded nagios (/usr/src), and extract it using command:

cd /usr/src
tar xzf nagios-4.1.1.tar.gz

Change to the nagios directory:

cd nagios-4.1.1/

Run the following commands one by one from the Terminal to compile and install nagios.

./configure --with-nagios-user=nagios --with-nagios-group=nagcmd --with-openssl
make all
make install
make install-init
make install-config
make install-commandmode

Install Nagios Web interface

Enter the following commands to compile and install nagios web interface.

make install-webconf

You may get the following error:

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
/usr/bin/install: cannot create regular file ‘/etc/httpd/conf.d/nagios.conf’: No such file or directory
Makefile:296: recipe for target 'install-webconf' failed
make: *** [install-webconf] Error 1

The above error message describes that nagios is trying to create the nagios.conf file inside the /etc/httpd.conf/directory. But, in Ubuntu systems the nagios.conf file should be placed in /etc/apache2/sites-enabled/directory.

So, run the following command instead of using make install-webconf.

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf

Check if nagios.conf is placed in /etc/apache2/sites-enabled directory.

ls -l /etc/apache2/sites-enabled/

Sample output:

total 4
lrwxrwxrwx 1 root root   35 oct  5  2015 000-default.conf -> ../sites-available/000-default.conf
-rw-r--r-- 1 root root 1679 abr 11 13:32 nagios.conf

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account. You’ll need it while logging in to nagios web interface..

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.

systemctl restart apache2

Install Nagios plugins

Go to the directory where you downloaded the nagios plugins (/usr/src), and extract it.

cd /usr/src
tar xzf nagios-plugins-2.1.1.tar.gz

Change to the nagios plugins directory:

cd nagios-plugins-2.1.1/

Run the following commands one by one to compile and install it.

./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make
make install

Check Nagios and generate Init Script

Check nagios,conf file for any syntax errors:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Create the Init Script copying /etc/init.d/skeleton to /etc/init.d/nagios using the following command:

cp /etc/init.d/skeleton /etc/init.d/nagios

Edit file /etc/init.d/nagios:

vim /etc/init.d/nagios

Add the following lines:

DESC="Nagios"
NAME=nagios
DAEMON=/usr/local/nagios/bin/$NAME
DAEMON_ARGS="-d /usr/local/nagios/etc/nagios.cfg"
PIDFILE=/usr/local/nagios/var/$NAME.lock

Save and close the file.

Finally you need to change the permissions of the file

chmod +x /etc/init.d/nagios

Now, you can start nagios service using command:

/etc/init.d/nagios start
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Access Nagios Web Interface

Open up your web browser and navigate to http://nagios-server-ip/nagios and enter the username as nagiosadmin and its password which we created in the earlier steps.

 

Possible issues

If you have an error with PING checks “Could not interpret output from ping command” apply this fix:

chmod u+s /bin/ping

Reference Links:

Print Friendly

Pablo Javier Furnari

Linux System Administrator at La Plata Linux
I'm a Linux Sysadmin with 8 years of experience. I work with several clients as a consulter here in Argentina and oversea (I have clients in the United States, Mexico, Pakistan and Germany).

I know my strengths and weaknesses. I'm a quick learner, I know how to work with small and big teams. I'm hard worker, proactive and I achieve everything I propose.

One thought on “Install Nagios Core 4.1.1 in Debian Jessie Part 1

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image