Nagios 4.0.7 installation and configuration on Cent OS 7.0

Nagios is a network monitoring application that provides monitoring and alerting services for servers, switches, applications, and services. It runs periodic checks on user-specified resources and services to evaluate both local system and remote hosts. System Resources that can be monitored are CPU, memory and disk space loads, log files, temperature or hardware errors. It also checks on various damages to crucial system services like HTTP, SMTP, DNS…. By using plugins its functionality is usually highly extended. The utility has the capability to give a user email alerts and it has a cool user-friendly interface. This informative guide will assist you install the newest Nagios 4..x on CentOS 7, even though it can work extremely well on any system/distro similar to fedora or Red Hat.
Installing Nagios
A working installation of Apache/PHP should be running on your system, just in case you haven’t you can use the next info to setup the specified applications:

# yum install -y httpd php

Nagios 4.0 needs the following libraries compiled from source installed:

# yum install -y gcc glibc glibc-common make gd gd-devel net-snmp

create a non root user that will run the application;

# useradd nagios

Add group privileges that will allow the web interface execute commands

# groupadd nagcmd
# usermod -G nagcmd nagios
# usermod -G nagcmd apache

Next is to download the installation packages

# mkdir ~/nagios
 # cd ~/nagios

Nagios core applications and plugins can be retrieved from the following websites;

Nagios Core - http://sourceforge.net/projects/nagios/files/latest/download
Nagios Plugins - http://nagios-plugins.org/downloads/

Alternatively you can use wget;

# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.7.tar.gz
# wget http://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

Extract the files using tar;

# tar zxvf nagios-4.0.7.tar.gz
 # tar zxvf nagios-plugins-2.0.3.tar.gz

You need to compile and install the Nagios files:

# cd nagios-4.0.7
# ./configure --with-command-group=nagcmd

nagios configure

# make all
# make install

The init scripts need to be placed in their respective folders

# make install-init
# make install-command mode
# make install-config

Next using vi or your favorite editor, change the email address  nagios@localhost in the configuration file /usr/local/nagios/etc/objects/contacts.cfg to whichever one you would like to receive alerts and notifications from in this format:

# vim /usr/local/nagios/etc/objects/contacts.cfg

nagios contacts cfg

After we have installed Nagios, we also need to install the web component, and set up the username and password, which will be used by the web interface;

# make install-webconf
# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    New password:
    Re-type new password:
    Adding password for user nagiosadmin

Restart apache for the settings to take effect:

# systemctl start httpd.service

Nagios Plugins can be run using the following commands:

# cd ~/nagios/nagios-plugins-2.0.3 # ./configure --with-nagios-user=nagios --with-nagiosgroup=nagios # make # make install

You have also to automate its execution at boot using the next commands

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

And you should get the output from a terminal whilst executing it:

nagios verify

add the services to runs at boot with the following commands:

 # chkconfig --add nagios
  # chkconfig --level 35 nagios on

And start the service with the following command:

 # systemctl start nagios.service

Now that you have installed everything, you can access the web components via your browser by pasting the next URL http://localhost/nagios. In case you are requested for a password by the web interface you will type for username and password  “nagiosadmin” and the password that you entered in a step earlier.

To be able to monitor remote hosts or perform more complex functions, you will need to merge Nagios with NRPE on the hosts so as to enable you gather information and run the Nagios plugins remotely.

go to http://sourceforge.net/projects/nagios/files/nrpe-2.x/ to download the latest version of NRPE,, you can do this with wget and then extract it’s content:

# wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
 # tar zxvf nrpe-2.15.tar.gz
 # cd nrpe-2.15

Next compile nrpe

#./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local
#make all
#sudo make install



Advertisements

Comments are closed.

%d bloggers like this: