Powered by Blogger.

Saturday, April 12, 2014

Installing Nagios on RedHat based system

Nagios is an awesome Open Source monitoring tool, its provides you more comprehensive monitoring environment to always keep an eye on your all machines / networks whether you are in a your data center or just your small labs.
With Nagios, you can monitor your remote hosts and their services remotely on a single window. It shows warnings and indicates if something goes wrong in your servers which eventually helps us to detect some problems before they occur. It helps us to reducedowntime and business losses.
Recently, Nagios released its latest versions Nagios 4.0.1 on 15th October 2013, and its latest stable release of Nagios plugins 1.5.
This article is intended to guide you with easy instructions on how to install latest Nagios 4.0.1 from source (tarball) on RHEL 6.4/6.3/6.2/6.1/6/5.8CentOS 6.4/6.3/6.2/6.1/6/5.8 and Fedora 19,18,17,16,15,14,13,12 distributions. Within 30 minutes you will be monitoring your local machine, no any advanced installation procedure only basic installation that will work 100%on most of the today’s Linux servers.
Follow the steps below :
 1. Install the following pre-requisites
[root@foo1 ~]# yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp
2. Download the Nagios packages
[root@foo1 ~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.0.tar.gz

3. Untar the tar ball

[root@foo1 ~]# tar -xvzf nagios-4.0.0.tar.gz

4. Create nagios system user

[root@foo1 ~]# useradd nagios

5. Run configure

[root@foo1 ~]# cd nagios
[root@foo1 nagios]# ./configure
...
...
*** Configuration summary for nagios 4.0.0 09-20-2013 ***:

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagios
             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.

6. Run make

[root@foo1 nagios]# make all
[root@foo1 nagios]# make install
[root@foo1 nagios]# make install-init
[root@foo1 nagios]# make install-config
[root@foo1 nagios]# make install-commandmode
[root@foo1 nagios]# make install-webconf

7. Check Nagios Core 4.0.0 configuration for errors

[root@foo1 nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
...
...
Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

8. Create Nagios Core 4.0.0 Apache user

[root@foo1 nagios]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

9. Install EPEL Repository

[root@foo1 nagios]# rpm -ivh http://ftp-stud.hs-esslingen.de/pub/epel/6/i386/epel-release-6-8.noarch.rpm

10. Install Nagios plugins

[root@foo1 nagios]# yum install nagios-plugins-all -y

11. Create a link to Nagios plugins directory

[root@foo1 nagios]# rm -rf /usr/local/nagios/libexec
[root@foo1 nagios]# ln -s /usr/lib/nagios/plugins/ /usr/local/nagios/libexec
[root@foo1 nagios]# chown -R nagios:nagios /usr/local/nagios/libexec

12. UPDATE: Add apache user to nagios group in /etc/group file

nagios:x:500:apache

13. Start Apache server

[root@foo1 nagios]# /etc/init.d/httpd start

14. Start Nagios Core 4.0.0 service

[root@foo1 nagios]# /etc/init.d/nagios start

15. Visit Nagios URL in your browser

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


0 comments

Post a Comment