Installing Nagios 3.4.4 On CentOS 6.3

Introduction

Nagios is a monitoring tool under GPL licence. This tool lets you monitor servers, network hardware (switches, routers, ...) and applications. A lot of plugins are available and its big community makes Nagios the biggest open source monitoring tool. This tutorial shows how to install Nagios 3.4.4 on CentOS 6.3.

 

Prerequisites

After installing your CentOS server, you have to disable selinux & install some packages to make nagios work.

To disable selinux, open the file: /etc/selinux/config

# vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive // change this value to disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Now, download all packages you need:

# yum install gd gd-devel httpd php gcc glibc glibc-common

 

Nagios Installation

Create a directory:

# mkdir /root/nagios

Navigate to this directory:

# cd /root/nagios

Download nagios-core & plugin:

# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.4.tar.gz
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

Untar nagios core:

# tar xvzf nagios-3.4.4.tar.gz

 Go to the nagios dir:

# cd nagios

Configure before make:

# ./configure

Make all necessary files for Nagios:

# make all

Installation:

# make install

# make install-init

# make install-commandmode

# make install-config

# make install-webconf

Create a password to log into the web interface:

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

Start the service and start it on boot:

# chkconfig nagios on
# service nagios start

Now, you have to install the plugins:

# cd ..
# tar xvzf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure
# make
# make install

 Start the apache service and enable it on boot:

# service httpd start
# chkconfig httpd on

Now, connect to your nagios system:

http://Your-Nagios-IP/nagios and enter login : nagiosadmin & password you have chosen above.

 

And after the installation ?

After the installation you have to configure all your host & services in nagios configuration files.This step is performed in command line and is complicated, so I recommand to install tool like Centreon, that is a beautiful front-end to add you host & services.

To go further, I recommend you to read my article on Nagios & Centreon monitoring.

Share this page:

16 Comment(s)

Add comment

Comments

From: at: 2013-01-29 08:24:57

Hi,

thanks for the HOWTO, just my two cents:

* Starting the HOWTO by telling the readers to disable the SELinux is a bad practice. Nagios is working smoothly with SELinux even in enforced mode, but to let the SELinux stay in permissive mode is better than nothing.

 

Hint:

cat /var/log/secure | audit2allow

 

Just pick-up the Nagios entries, create a new policy file with

audit2allow -M

and load with

semodule

 

* Because the strongly preffered software management in CentOS is the RPM packages, and the Nagios 3.3 is in EPEL repo, the alternate end of this HOWTO could be just altering the nagios.spec and build a RPM instead of compiling and installing directly in filesystem...

From: OERNii at: 2013-01-31 09:53:04

nagios is a PITA to get to work under selinux. i have it disabled after 3 days of fight. Also use the RPM, not the source.

From: Marty at: 2013-02-11 15:40:51

The following is from the Nagios Manual:
 
The biggest advantage of installing from source is that the installation process can be repeated on almost any Linux distribution. This aspect is even more important when you consider that whether you install from a RPM repository (CentOS) or from a DEB repository (Ubuntu) the file names and locations for files are different in each case. The implications for documentation are that you must translate any documentation to the installation method that was chosen.
Another significant advantage of compiling from source is that you have more options so the configuration may be altered to meet specific requirements. Of course, any changes to the defaults mean that the documentations and other dependencies must be evaluated per the changes from the default. The installation of Nagios must be performed as root.

From: Anonymous at: 2013-01-31 10:36:38

Not only is advising to disable SELinux bad practice, so is the approach of building as root.

And why would one even build from a tarball when the Fedora EPEL repo already provides an RPM. Rather get that, or build from the SRPM: ftp://ftp.nluug.nl/site/download.fedora.redhat.com/pub/fedora-epel/6/SRPMS/nagios-3.4.4-1.el6.src.rpm

 

From: The Sysadmin Himself at: 2013-02-17 10:51:58

I was able to make this work without disabling SELinux. You essentially have to add the PHP directories with semanage. See my blog post on this: Configuring SELinux for Centeron 2.4 on CentOS 6.3.

A guide to install Centreon on CentOS.

From: Bourne at: 2013-03-18 07:18:56

can't access nagios 3.4.4 web interface

 

Not Found

The requested URL /nagios/ was not found on this server.


Apache/2.2.15 (CentOS) DAV/2 PHP/5.3.3 mod_ssl/2.2.15 OpenSSL/1.0.0-fips Server at 192.168.46.51 Port 80

 

From: Anonymous at: 2013-05-03 09:49:06

Im having the same error. HELP!!!!!!! I dont know why???

Not Found

The requested URL /nagios was not found on this server.


Apache/2.2.15 (CentOS) Server at 127.0.0.1 Port 80

 

From: Anonymous at: 2013-07-09 17:14:01

Did you find why you had this problem? I have the same problem.

From: Anonymous at: 2013-07-17 16:19:22

I got the same error and had to restart httpd process to pick up the conf.d changes.

if that doesn't work, look at the nagios config file in the conf.d dir for apache and look at what the alias and file path for /nagios/ is.

From: Anonymous at: 2013-03-19 05:42:28

how to log out nagios web interface brooo...

From: Joseph at: 2013-03-22 15:44:10

Some useful info here if you got stuck....

From: Stuart Macfarlane at: 2013-04-04 21:52:10

Don't forget to make sure you have "make" and "perl" installed also.

If you don't have "make" installed you won't be able to complete the part after ./configure. Also if you don't have "perl" installed you will have errors at the end of the ./configure command and won't be able to run make all.

From: Abhishek at: 2013-04-18 11:24:18

the information provided by u is really fruitful and accurate.

From: Anonymous at: 2013-08-02 06:46:05

After installing nagios, if you are getting forbidden 403 error then don't forget to add index.php in your httpd.conf index section.

From: at: 2014-12-20 19:06:41

This HOWTO was written for 6.3

 If you are now using centos 6.4+ it can be found in EPEL and installed with yum

From: Ancalagon at: 2015-04-15 01:31:26

First I modified the nagios folder structure's SELinux labels to allow httpd read access:# chcon -R --reference=/var/www/html /usr/local/nagios/share# chcon -R --reference=/var/www/html /usr/local/nagios/var# chcon -R --reference=/var/www/cgi-bin /usr/local/nagios/sbinNext I changed the ~var/rw folder to allow write access via the httpd_sys_rw_content_t label:# chcon -R -t httpd_sys_rw_content_t /usr/local/nagios/var/rw