Install Nagios Core 4.0 on CentOS 6.4

Posted: November 5, 2013 in Linux, Nagios
Tags: , ,

New Nagios Core 4. has been released and is available for download.

Nagios Core 4.0.0 brings performance enhancements and new features:
Performance Improvements
Query Handler: The query handler provides a simple interface for external entities communicating with Nagios Core. Core workers use the query handler interface.
Core Workers: The process of performing checks is now handled by a lightweight core worker process.
libnagios: libnagios is a library of functions useful to developers of query handlers and core workers.

Read more here

Install Nagios Core 4 on CentOS 6 64bit!

Nagios and its plugins will be installed under /usr/local/nagios directory.

Update CentOS and install required dependency packages

# yum update
# yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

User and Group Accounts

Create a new nagios user and nagcmd group account and set a password.

# useradd nagios
# groupadd nagcmd

Next, add both the nagios user and the apache user to the nagcmd group.

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

Download Nagios Core 4

Create a folder for Nagios:

# mkdir /etc/nagios
# cd /etc/nagios

Download the latest Nagios Core tarball (replace the link after wget if there is a newer version). Always check for the latest version at the Nagios website.

# wget

Untar Nagios Core 4

# tar xvf nagios-4.0.1.tar.gz

After extracting these tarballs with the tar command, a new folder will appear in that directory: nagios-4.0.1

Configure Nagios Core

Now, first we will configure Nagios Core and to do so we need to go to Nagios directory and run configure file and if everything goes fine, it will show the output in the end as sample output. Please see below.

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

Sample output:

*** Configuration summary for nagios 4.0.1 10-15-2013 ***:

 General Options:
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  ${prefix}/var/nagios.lock
   Check result directory:  ${prefix}/var/spool/checkresults
           Init directory:  /etc/rc.d/init.d
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu

 Web Interface Options:
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):

Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

Run the following make commands

Now, after configuring we need to Compile and install all the binaries with the “make” command and the “make install” command.

# make all
*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface

  make install-exfoliation
     - This installs the Exfoliation theme for the Nagios
       web interface

  make install-classicui
     - This installs the classic theme for the Nagios
       web interface

*** Support Notes *******************************************

If you have questions about configuring or running Nagios,
please make sure that you:

     - Look at the sample config files
     - Read the documentation on the Nagios Library at:

before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you.  This might include:

     - What version of Nagios you are using
     - What version of the plugins you are using
     - Relevant snippets from your config files
     - Relevant error messages from the Nagios log file

For more information on obtaining support for Nagios, visit:



This will install all the needed libraries in your machine.

# make install

*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs sample config files in /usr/local/nagios/etc

make[1]: Leaving directory `/etc/nagios/nagios-4.0.1'

Following command will install the init scripts for Nagios.

# make install-init

*** Init script installed ***

To make nagios work from command line we need to install command-mode.

# make install-commandmode
*** External command directory configured ***

Next, install sample nagios files, please run following command.

# make install-config

*** Config files installed ***Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

Install and Configure Web Interface for Nagios

We are done with all configuration in the backend, now we will configure Web Interface For Nagios with following command. The below command will Configure Web interface for Nagios and a web admin user will be created “nagiosadmin”.

# make install-webconf

In this step, we will be creating a password for “nagiosadmin”. After executing this command, please provide a password twice and keep it remember because this password will be used when you login in the Nagios Web interface.

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

Add Nagios Services to System Startup

To make Nagios work across reboots, we need to add nagios and httpd with chkconfig command.

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

Start the services.

# service httpd start 
# service nagios start

Visit Nagios URL in your browser

Open http://IPADDRESS/nagios or http://FQDN/nagios in your browser and enter username and password created.

More about how to configure Nagios hosts and services in my following posts on Nagios Configuration!

Also a big thanks to:
Alexandre Nogard –
Mitch –
Tarunika Shrivastava –

  1. Chris says:

    This is great, if you don’t mind, I’d like to build an install-able RPM using your information here and make it a 1 stop shop and install. Would you be okay with that? I will reference your blog (as well as mine) in the spec file too (as I’m not here to deny or steal you of any credit and great work).

  2. […] Install Nagios Core 4.0 on CentOS 6.4 ( […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s