Thursday, 11 July 2013

Install Nagios Core 4.0 From Source in Less Than Ten Minutes!

1. Prerequisites

Before installing Nagios, make sure that the following packages are installed.

 GCC Compiler
 GD development libraries

login as root and install it.

# yum install -y httpd php gcc glibc glibc-common gd gd-devel openssl openssl-devel wget

2. Create user and group for Nagios

Now we need to create an user account (nagios) and a group account (nagcmd) for Nagios. Then add apache and nagios user account to the created group.

# useradd -m nagios
# passwd nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

3. Download Nagios Core and Nagios Plugins Tarballs

Create a temporary folder for the downloads and download the latest version of Nagios Core and plugins

# mkdir downloads
# cd downloads

# wget

# wget

4. Extract, compile and install Nagios

# tar zxvf nagios-4.0.0-beta1.tar.gz
# cd nagios
# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode

5. Configure the web interface

Install the Nagios web config file in the Apache conf.d directory.
# make install-webconf

Create an account for logging into the Nagios web interface.
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

6. Compile and install nagios plugins

# tar zxvf nagios-plugins-1.4.16.tar.gz
# cd nagios-plugins-1.4.16
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install

7. Verify to make sure there are no errors in the nagios configuration file

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Apache and Nagios
# service httpd start
# service nagios start

8. Start Nagios and Apache when the system boots

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

9. Nagios Web Interface

After correctly following the procedures you should now be able to access your Nagios Core installation from a web browser.

Simply use the following:
And log in with the credentials you chose when adding the admin user to the htpasswd.users file.

Note 1:

Nagios HTTP WARNING: HTTP/1.1 403 Forbidden alert

When you newly set up Nagios server you may get this alert “Nagios HTTP WARNING: HTTP/1.1 403 Forbidden”. This is because Nagios is looking for index pages in the Apache or HTTP Root directory. To resolve this issue you need to create an index.html file inside /var/www/html directory.

# cd /var/www/html
# touch index.html
# service nagios restart
# service httpd restart

Note 2:

If you have SELinux installed and with the enforcing mode by default, you probably get some errors in Nagios web interface. You'll need to change the SELinux context of some Nagios folders.

# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
# chcon -R -t httpd_sys_script_rw_t /usr/local/nagios/var/rw/

You may disable the SELINUX by changing SELINUX=enforcing to SELINUX=disabled in the /etc/selinux/config file.

No comments:

Post a Comment