Installing Nagios 3.4.4 On CentOS 6.3

Want to support HowtoForge? Become a subscriber!
 
Submitted by alexnogard (Contact Author) (Forums) on Mon, 2013-01-28 20:11. :: CentOS | Monitoring

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.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Fri, 2013-08-02 07:46.
After installing nagios, if you are getting forbidden 403 error then don't forget to add index.php in your httpd.conf index section.
Submitted by Abhishek (not registered) on Thu, 2013-04-18 12:24.
the information provided by u is really fruitful and accurate.
Submitted by Stuart Macfarlane (not registered) on Thu, 2013-04-04 22:52.

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.

Submitted by Joseph (not registered) on Fri, 2013-03-22 16:44.
Some useful info here if you got stuck....
Submitted by Anonymous (not registered) on Tue, 2013-03-19 06:42.
how to log out nagios web interface brooo...
Submitted by Bourne (not registered) on Mon, 2013-03-18 08:18.

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

 

Submitted by Anonymous (not registered) on Fri, 2013-05-03 10:49.

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

 

Submitted by Anonymous (not registered) on Tue, 2013-07-09 18:14.
Did you find why you had this problem? I have the same problem.
Submitted by Anonymous (not registered) on Wed, 2013-07-17 17:19.

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.

Submitted by The Sysadmin Himself (not registered) on Sun, 2013-02-17 11:51.

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.

Submitted by xMstSpider (registered user) on Tue, 2013-01-29 09:24.

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...

Submitted by Anonymous (not registered) on Thu, 2013-01-31 11:36.

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

 

Submitted by OERNii (not registered) on Thu, 2013-01-31 10:53.
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.
Submitted by Marty (not registered) on Mon, 2013-02-11 16:40.
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.