How to Install Nagios on CentOS 5.5

Nagios is a popular open source system and network monitoring software application. It monitor hosts and services and then alerting users when something wrong has been triggered. It is the powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Below is the steps to install Nagios on CentOS 5.5 server. This tutorial assume that you already installed LAMP (Linux CentOS, Apache, Mysql and PHP) server.

Prerequisites
How to Install Apache Httpd Web Server on Linux
Install or updates the prerequisites. Make sure that all of these packages already installed and properly configured.

    [root@server ~]# yum -y --enablerepo=rpmforge install httpd php gcc glibc glibc-common gd gd-devel
    

Steps :
1. Download and install the rpmforge repository.

For x86 (32-bit) systems

    [root@server ~]# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
    

For x64 (64-bit) systems

    [root@server ~]# rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
    

2. Install Nagios and Plugins using yum command

    [root@server ~]# yum -y --enablerepo=rpmforge install nagios nagios-plugins nagios-plugins-setuid
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * addons: centos.maulvi.net
    * base: centos.maulvi.net
    * epel: ftp.cuhk.edu.hk
    * extras: centos.maulvi.net
    * rpmforge: fr2.rpmfind.net
    * updates: mirror.yourconnect.com
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package nagios.i386 0:3.2.3-3.el5.rf set to be updated
    ---> Package nagios-plugins.i386 0:1.4.15-2.el5.rf set to be updated
    --> Processing Dependency: fping for package: nagios-plugins
    --> Processing Dependency: perl(Net::SNMP) for package: nagios-plugins
    ---> Package nagios-plugins-setuid.i386 0:1.4.15-2.el5.rf set to be updated
    --> Running transaction check
    ---> Package fping.i386 0:2.4b2-7.el5 set to be updated
    ---> Package perl-Net-SNMP.noarch 0:5.2.0-1.2.el5.rf set to be updated
    --> Processing Dependency: perl(Crypt::DES) for package: perl-Net-SNMP
    --> Running transaction check
    ---> Package perl-Crypt-DES.i386 0:2.05-3.2.el5.rf set to be updated
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =====================================================================================
    Package                    Arch        Version                  Repository     Size
    =====================================================================================
    Installing:
    nagios                     i386        3.2.3-3.el5.rf           rpmforge      3.7 M
    nagios-plugins             i386        1.4.15-2.el5.rf          rpmforge      1.6 M
    nagios-plugins-setuid      i386        1.4.15-2.el5.rf          rpmforge      122 k
    Installing for dependencies:
    fping                      i386        2.4b2-7.el5              epel           30 k
    perl-Crypt-DES             i386        2.05-3.2.el5.rf          rpmforge       37 k
    perl-Net-SNMP              noarch      5.2.0-1.2.el5.rf         rpmforge       96 k
    
    Transaction Summary
    =====================================================================================
    Install       6 Package(s)
    Upgrade       0 Package(s)
    
    Total download size: 5.6 M
    Downloading Packages:
    (1/6): fping-2.4b2-7.el5.i386.rpm                             |  30 kB     00:02
    (2/6): perl-Crypt-DES-2.05-3.2.el5.rf.i386.rpm                |  37 kB     00:00
    (3/6): perl-Net-SNMP-5.2.0-1.2.el5.rf.noarch.rpm              |  96 kB     00:02
    (4/6): nagios-plugins-setuid-1.4.15-2.el5.rf.i386.rpm         | 122 kB     00:03
    (5/6): nagios-plugins-1.4.15-2.el5.rf.i386.rpm                | 1.6 MB     00:28
    (6/6): nagios-3.2.3-3.el5.rf.i386.rpm                         | 3.7 MB     01:07
    -------------------------------------------------------------------------------------
    Total                                                 53 kB/s | 5.6 MB     01:48
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Installing     : fping                                                         1/6
    Installing     : perl-Crypt-DES                                                2/6
    Installing     : nagios-plugins-setuid                                         3/6
    Installing     : nagios                                                        4/6
    Installing     : perl-Net-SNMP                                                 5/6
    Installing     : nagios-plugins                                                6/6
    
    Installed:
    nagios.i386 0:3.2.3-3.el5.rf                 nagios-plugins.i386 0:1.4.15-2.el5.rf
    nagios-plugins-setuid.i386 0:1.4.15-2.el5.rf
    
    Dependency Installed:
    fping.i386 0:2.4b2-7.el5                   perl-Crypt-DES.i386 0:2.05-3.2.el5.rf
    perl-Net-SNMP.noarch 0:5.2.0-1.2.el5.rf
    
    Complete!
    

3. Create the default Nagios user and set a password using htpasswd:

    [root@server ~]# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
    New password:
    Re-type new password:
    Adding password for user nagiosadmin
    

4. Verify default config files using below command :

    [root@server ~]# nagios -v /etc/nagios/nagios.cfg
    
    Nagios Core 3.2.3
    Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
    Copyright (c) 1999-2009 Ethan Galstad
    Last Modified: 10-03-2010
    License: GPL
    
    Website: http://www.nagios.org
    Reading configuration data...
    Read main config file okay...
    Processing object config file '/etc/nagios/objects/commands.cfg'...
    Processing object config file '/etc/nagios/objects/contacts.cfg'...
    Processing object config file '/etc/nagios/objects/timeperiods.cfg'...
    Processing object config file '/etc/nagios/objects/templates.cfg'...
    Processing object config file '/etc/nagios/objects/localhost.cfg'...
    Read object config files okay...
    
    Running pre-flight check on configuration data...
    
    Checking services...
    Checked 8 services.
    Checking hosts...
    Checked 1 hosts.
    Checking host groups...
    Checked 1 host groups.
    Checking service groups...
    Checked 0 service groups.
    Checking contacts...
    Checked 1 contacts.
    Checking contact groups...
    Checked 1 contact groups.
    Checking service escalations...
    Checked 0 service escalations.
    Checking service dependencies...
    Checked 0 service dependencies.
    Checking host escalations...
    Checked 0 host escalations.
    Checking host dependencies...
    Checked 0 host dependencies.
    Checking commands...
    Checked 24 commands.
    Checking time periods...
    Checked 5 time periods.
    Checking for circular paths between hosts...
    Checking for circular host and service dependencies...
    Checking global event handlers...
    Checking obsessive compulsive processor commands...
    Checking misc settings...
    
    Total Warnings: 0
    Total Errors:   0
    
    Things look okay - No serious problems were detected during the pre-flight check
    

5. Configure nagiso service to start at boot

    [root@server ~]# chkconfig nagios on
    

6. Start the nagios service

    [root@server ~]# /etc/init.d/nagios start
    nagios is stopped
    Starting nagios:                                           [  OK  ]
    

7. Restart apache server

    [root@server ~]# /etc/init.d/httpd restart
    Stopping httpd:                                            [  OK  ]
    Starting httpd:                                            [  OK  ]
    

8. To login, navigate your browser to http://servername/nagios

Comments

2 Comments

Leave a Reply to Ali Cancel reply

Your email address will not be published. Required fields are marked *