How to Install Nagios Monitoring Server on CentOS 6.5

Nagios is one of the alternate open source computer, network and infrastructure monitoring system that will help organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Nagios provides host, service and network monitoring capabilities and was designed with scalability and flexibility. With complete monitoring and alerting, nagios allows you to detect and repair problems and mitigate future issues before they affect end-users and customers. This post will show you how you can install Nagios monitoring server on CentOS 6.5

1. Prepare and download EPEL repository :

[root@centos6-05 ~]# wget dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

2. Install EPEL repository :

[root@centos6-05 ~]# rpm -Uvh epel-release-6-8.noarch.rpm
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
1:epel-release           ########################################### [100%]

3. Install Nagis packages, php and httpd web server :

[root@centos6-05 ~]# yum install nagios nagios-plugins-all nagios-plugins-nrpe nrpe php httpd -y

Example:

[root@centos6-05 ~]# yum install nagios nagios-plugins-all nagios-plugins-nrpe nrpe php httpd -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * Webmin: download.webmin.com
 * base: mirror.upsi.edu.my
 * epel: mirror.smartmedia.net.id
 * extras: mirror.upsi.edu.my
 * updates: mirror.upsi.edu.my
Setting up Install Process
Package php-5.3.3-27.el6_5.x86_64 already installed and latest version
Package httpd-2.2.15-29.el6.centos.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package nagios.x86_64 0:3.5.1-1.el6 will be installed
--> Processing Dependency: user(nagios) for package: nagios-3.5.1-1.el6.x86_64
--> Processing Dependency: user(nagios) for package: nagios-3.5.1-1.el6.x86_64
--> Processing Dependency: nagios-common for package: nagios-3.5.1-1.el6.x86_64
--> Processing Dependency: mailx for package: nagios-3.5.1-1.el6.x86_64
--> Processing Dependency: group(nagios) for package: nagios-3.5.1-1.el6.x86_64
--> Processing Dependency: group(nagios) for package: nagios-3.5.1-1.el6.x86_64
--> Processing Dependency: libgd.so.2()(64bit) for package: nagios-3.5.1-1.el6.x86_64
---> Package nagios-plugins-all.x86_64 0:1.4.16-10.el6 will be installed
--> Processing Dependency: nagios-plugins-wave for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-users for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ups for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-time for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-tcp for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-swap for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ssh for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-snmp for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-smtp for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-sensors for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-rpc for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-real for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-procs for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ping for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-pgsql for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-overcr for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-oracle for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-nwstat for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ntp-perl for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ntp for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-nt for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-nagios for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-mysql for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-mrtgtraf for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-mrtg for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-mailq for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-log for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-load for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ldap for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ircd for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-ide_smart for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-icmp for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-http for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-hpjd for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-game for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-fping for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-flexlm for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-file_age for package: nagios-plugins-all-1.4.16-10.el6.x86_64
--> Processing Dependency: nagios-plugins-dummy for package: nagios-plugins-all-1.4.16-10.el6.x86_64
..
..
..

Installed:
  nagios.x86_64 0:3.5.1-1.el6                     nagios-plugins-all.x86_64 0:1.4.16-10.el6
  nagios-plugins-nrpe.x86_64 0:2.14-5.el6         nrpe.x86_64 0:2.14-5.el6

Dependency Installed:
  dmidecode.x86_64 1:2.11-2.el6                    fontconfig.x86_64 0:2.8.0-3.el6
  fping.x86_64 0:2.4b2-10.el6                      gd.x86_64 0:2.0.35-11.el6
  libgssglue.x86_64 0:0.1-11.el6                   libtalloc.x86_64 0:2.0.7-2.el6
  libtdb.x86_64 0:1.2.10-1.el6                     libtevent.x86_64 0:0.9.18-3.el6
  libtirpc.x86_64 0:0.2.1-6.el6_4                  lm_sensors.x86_64 0:3.1.1-17.el6
  mailx.x86_64 0:12.4-7.el6                        nagios-common.x86_64 0:3.5.1-1.el6
  nagios-plugins.x86_64 0:1.4.16-10.el6            nagios-plugins-breeze.x86_64 0:1.4.16-10.el6
  nagios-plugins-by_ssh.x86_64 0:1.4.16-10.el6     nagios-plugins-cluster.x86_64 0:1.4.16-10.el6
  nagios-plugins-dhcp.x86_64 0:1.4.16-10.el6       nagios-plugins-dig.x86_64 0:1.4.16-10.el6
  nagios-plugins-disk.x86_64 0:1.4.16-10.el6       nagios-plugins-disk_smb.x86_64 0:1.4.16-10.el6
  nagios-plugins-dns.x86_64 0:1.4.16-10.el6        nagios-plugins-dummy.x86_64 0:1.4.16-10.el6
  nagios-plugins-file_age.x86_64 0:1.4.16-10.el6   nagios-plugins-flexlm.x86_64 0:1.4.16-10.el6
  nagios-plugins-fping.x86_64 0:1.4.16-10.el6      nagios-plugins-game.x86_64 0:1.4.16-10.el6
  nagios-plugins-hpjd.x86_64 0:1.4.16-10.el6       nagios-plugins-http.x86_64 0:1.4.16-10.el6
  nagios-plugins-icmp.x86_64 0:1.4.16-10.el6       nagios-plugins-ide_smart.x86_64 0:1.4.16-10.el6
  nagios-plugins-ircd.x86_64 0:1.4.16-10.el6       nagios-plugins-ldap.x86_64 0:1.4.16-10.el6
  nagios-plugins-load.x86_64 0:1.4.16-10.el6       nagios-plugins-log.x86_64 0:1.4.16-10.el6
  nagios-plugins-mailq.x86_64 0:1.4.16-10.el6      nagios-plugins-mrtg.x86_64 0:1.4.16-10.el6
  nagios-plugins-mrtgtraf.x86_64 0:1.4.16-10.el6   nagios-plugins-mysql.x86_64 0:1.4.16-10.el6
  nagios-plugins-nagios.x86_64 0:1.4.16-10.el6     nagios-plugins-nt.x86_64 0:1.4.16-10.el6
  nagios-plugins-ntp.x86_64 0:1.4.16-10.el6        nagios-plugins-ntp-perl.x86_64 0:1.4.16-10.el6
  nagios-plugins-nwstat.x86_64 0:1.4.16-10.el6     nagios-plugins-oracle.x86_64 0:1.4.16-10.el6
  nagios-plugins-overcr.x86_64 0:1.4.16-10.el6     nagios-plugins-perl.x86_64 0:1.4.16-10.el6
  nagios-plugins-pgsql.x86_64 0:1.4.16-10.el6      nagios-plugins-ping.x86_64 0:1.4.16-10.el6
  nagios-plugins-procs.x86_64 0:1.4.16-10.el6      nagios-plugins-real.x86_64 0:1.4.16-10.el6
  nagios-plugins-rpc.x86_64 0:1.4.16-10.el6        nagios-plugins-sensors.x86_64 0:1.4.16-10.el6
  nagios-plugins-smtp.x86_64 0:1.4.16-10.el6       nagios-plugins-snmp.x86_64 0:1.4.16-10.el6
  nagios-plugins-ssh.x86_64 0:1.4.16-10.el6        nagios-plugins-swap.x86_64 0:1.4.16-10.el6
  nagios-plugins-tcp.x86_64 0:1.4.16-10.el6        nagios-plugins-time.x86_64 0:1.4.16-10.el6
  nagios-plugins-ups.x86_64 0:1.4.16-10.el6        nagios-plugins-users.x86_64 0:1.4.16-10.el6
  nagios-plugins-wave.x86_64 0:1.4.16-10.el6       net-snmp-utils.x86_64 1:5.5-49.el6
  ntp.x86_64 0:4.2.6p5-1.el6.centos                ntpdate.x86_64 0:4.2.6p5-1.el6.centos
  openssh-clients.x86_64 0:5.3p1-94.el6            qstat.x86_64 0:2.11-9.20080912svn311.el6
  rpcbind.x86_64 0:0.2.0-11.el6                    samba-client.x86_64 0:3.6.9-167.el6_5
  samba-common.x86_64 0:3.6.9-167.el6_5            samba-winbind.x86_64 0:3.6.9-167.el6_5
  samba-winbind-clients.x86_64 0:3.6.9-167.el6_5

Complete!

4. Make httpd and nagios software auto start at boot :

[root@centos6-05 ~]# chkconfig httpd on
[root@centos6-05 ~]# chkconfig nagios on

5. Start httpd and nagios software :

[root@centos6-05 ~]# service httpd start
Starting httpd:                                            [  OK  ]
[root@centos6-05 ~]# service nagios start
Starting nagios: done.

6. Set Nagios Admin Panel Password:

[root@centos6-05 ~]# htpasswd -c /etc/nagios/passwd nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

7. Navigate over to your IP address http://IPADDRESS/nagios and login using above “nagiosadmin” > However, you still able to change /etc/nagios/cgi.cfg and redefine authorized admin anytime later.

[root@centos6-05 ~]# vi /etc/nagios/cgi.cfg
..
..
authorized_for_system_information=nagiosadmin
..
..

How to Monitor and Configure a Windows Server Using Nagios

In this post, i will guide you on how to configure windows machine using and will be monitor via nagios server.

Steps:
1. Download the latest stable version of the NSClient++ addon from http://nsclient.org/nscp/downloads
2. There are two alternate ways to install the NSClient++ on windows server.
a) Double click the file if you downloaded the .msi installer. Set the NSClient to ‘nagiospassword‘.
b) Go to this URL and read the manual properly:

    https://webhostinggeeks.com/howto/docs/nagios/monitoring-windows.html
    

3. Modify the nagios.cfg and add server1.cfg line under windows.cfg line.

    [root@server ~]# vi /etc/nagios/nagios.cfg
    
    # Definitions for monitoring a Windows machine
    #cfg_file=/etc/nagios/objects/windows.cfg
    cfg_file=/etc/nagios/objects/server1.cfg
    

4. Make a copy the original windows.cfg config file and rename it to server1.cfg, which is the preferred server name.

    [root@server ~]# cp /etc/nagios/objects/windows.cfg /etc/nagios/objects/server1.cfg
    

5. Define windows services that should be monitored.

    [root@server ~]# vi /etc/nagios/objects/server1.cfg
    
    # HOST DEFINITIONS
    
    # Define a host for the Windows machine we'll be monitoring
    # Change the host_name, alias, and address to fit your situation
    
    define host{
    	use		windows-server	; Inherit default values from a template
    	host_name	server1	; The name we're giving to this host
    	alias		My Windows Server	; A longer name associated with the host
    	address		192.168.2.2	; IP address of the host
    	}
    
    # HOST GROUP DEFINITIONS
    
    # Define a hostgroup for Windows machines
    # All hosts that use the windows-server template will automatically be a member of this group
    
    define hostgroup{
    	hostgroup_name	windows-servers	; The name of the hostgroup
    	alias		Windows Servers	; Long name of the group
    	}
    
    # Create a service for monitoring the version of NSCLient++ that is installed
    # Change the host_name to match the name of the host you defined above
    
    define service{
    	use			generic-service
    	host_name		server1
    	service_description	NSClient++ Version
    	check_command		check_nt!CLIENTVERSION
    	}
    
    # Create a service for monitoring the uptime of the server
    # Change the host_name to match the name of the host you defined above
    
    define service{
    	use			generic-service
    	host_name		server1
    	service_description	Uptime
    	check_command		check_nt!UPTIME
    	}
    
    # Create a service for monitoring CPU load
    # Change the host_name to match the name of the host you defined above
    
    define service{
    	use			generic-service
    	host_name		server1
    	service_description	CPU Load
    	check_command		check_nt!CPULOAD!-l 5,80,90
    	}
    
    # Create a service for monitoring memory usage
    # Change the host_name to match the name of the host you defined above
    
    define service{
    	use			generic-service
    	host_name		server1
    	service_description	Memory Usage
    	check_command		check_nt!MEMUSE!-w 80 -c 90
    	}
    
    # Create a service for monitoring C:\ disk usage
    # Change the host_name to match the name of the host you defined above
    
    define service{
    	use			generic-service
    	host_name		server1
    	service_description	C:\ Drive Space
    	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
    	}
    
    # Create a service for monitoring the W3SVC service
    # Change the host_name to match the name of the host you defined above
    
    define service{
    	use			generic-service
    	host_name		server1
    	service_description	W3SVC
    	check_command		check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
    	}
    
    # Create a service for monitoring the Explorer.exe process
    # Change the host_name to match the name of the host you defined above
    
    define service{
    	use			generic-service
    	host_name		server1
    	service_description	Explorer
    	check_command		check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
    	}
    

6. Enable Password protection for NSClient. Set the password same as ‘2.a)‘.

    # 'check_nt' command definition
    define command{
            command_name    check_nt
            command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s nagiospassword -v $ARG1$ $ARG2$
            }
    

7. Verify the configuration

    [root@server ~]# /usr/bin/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'...
    Processing object config file '/etc/nagios/objects/server1.cfg'...
       Read object config files okay...
    
    Running pre-flight check on configuration data...
    
    Checking services...
            Checked 15 services.
    Checking hosts...
            Checked 2 hosts.
    Checking host groups...
            Checked 2 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
    

8. Restart the Nagios service.

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

How to Install and Configure Nagios NRPE

In the previous article, i have guide you on how to install Nagios Core, mainly for network and services monitoring. In this post, i will guide you on how to install Nagios NRPE. Nagios Remote Plugin Executor (NRPE) is a Nagios agent that allows to remotely execute Nagios plugins on other Linux/Unix machines. NRPE can also communicate with Windows agent addons like NSClient++. It allows for monitoring resources such as disk usage, CPU load, etc. Please follow the following steps to install Nagios NRPE on your Nagios server.

Prerequisites
How to Install Nagios on CentOS 5.5

Steps:
1. Install the Nagios NRPE and Nagios-devel. For your information, Nagios-devel is a header files, libraries and development documentation for nagios.

    [root@server ~]# yum --enablerepo=rpmforge install nagios-nrpe nagios-devel
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * addons: ossm.utm.my
     * base: ossm.utm.my
     * epel: ftp.cuhk.edu.hk
     * extras: ossm.utm.my
     * rpmforge: fr2.rpmfind.net
     * updates: ossm.utm.my
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package nagios-devel.i386 0:3.2.3-3.el5.rf set to be updated
    ---> Package nagios-nrpe.i386 0:2.12-1.el5.rf set to be updated
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =====================================================================================
     Package               Arch          Version                 Repository         Size
    =====================================================================================
    Installing:
     nagios-devel          i386          3.2.3-3.el5.rf          rpmforge           42 k
     nagios-nrpe           i386          2.12-1.el5.rf           rpmforge           35 k
    
    Transaction Summary
    =====================================================================================
    Install       2 Package(s)
    Upgrade       0 Package(s)
    
    Total download size: 76 k
    Is this ok [y/N]: y
    Downloading Packages:
    (1/2): nagios-nrpe-2.12-1.el5.rf.i386.rpm                     |  35 kB     00:00
    (2/2): nagios-devel-3.2.3-3.el5.rf.i386.rpm                   |  42 kB     00:00
    -------------------------------------------------------------------------------------
    Total                                                 23 kB/s |  76 kB     00:03
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing     : nagios-nrpe                                                   1/2
      Installing     : nagios-devel                                                  2/2
    
    Installed:
      nagios-devel.i386 0:3.2.3-3.el5.rf         nagios-nrpe.i386 0:2.12-1.el5.rf
    
    Complete!
    

2. Set nrpe to start at boot and start nrpe

    [root@server ~]# chkconfig nrpe on
    [root@server ~]# /etc/init.d/nrpe start
    Starting Nagios NRPE daemon (nrpe):                        [  OK  ]
    

3. Update the /etc/services. At the following line at the bottom of the page.

    [root@server ~]# vi /etc/services
    
    nrpe            5666/tcp                        # NRPE
    

4. Test NRPE daemon install

    [root@server ~]# netstat -at |grep nrpe
    tcp        0      0 server.intranet.local:nrpe  *:*                         LISTEN
    

How to Configure LDAP Authentication for Nagios on CentOS 5.5

This article assume that you already installed the nagios server on LAMP CentOS server and also installed 389 directory server. On the previous tutorial, the user that allowed to manage nagios is nagiosadmin which has been created using htpasswd. In this article, i will show you on how configure LDAP authentication for Nagios on CentOS 5.5.

Prerequisites
How to Install Apache Httpd Web Server on Linuxrel=”nofollow”
How to Install 389 Directory Server on CentOS/RHEL

1. Configure nagios.conf and change it to your LDAP environment. Assume the following info is valid on LDAP server:

    Server ip = 192.168.2.5
    Suffix = dc=intranet, dc=local
    LDAP user : user1 ( most of the time, this user is sytem administrator)
    
    [root@server ~]# vi /etc/httpd/conf.d/nagios.conf
    
    ScriptAlias /nagios/cgi-bin "/usr/lib/nagios/cgi"
    
    <Directory "/usr/lib/nagios/cgi">
       Options ExecCGI
       AllowOverride None
       Order allow,deny
       Allow from all
       AuthBasicProvider ldap
       AuthType Basic
       AuthzLDAPAuthoritative on
       AuthName " LDAP Authentication for Nagios Monitoring"
       AuthLDAPURL "ldap://192.168.2.5:389/DC=intranet,DC=local?uid?sub?(objectClass=*)" NONE
       Require user
    </Directory>
    
    Alias /nagios "/usr/share/nagios"
    
    <Directory "/usr/share/nagios">
       Options None
       AllowOverride None
       Order allow,deny
       Allow from all
       AuthBasicProvider ldap
       AuthType Basic
       AuthzLDAPAuthoritative on
       AuthName " LDAP Authentication for Nagios Monitoring"
       AuthLDAPURL "ldap://192.168.2.5:389/DC=intranet,DC=local?uid?sub?(objectClass=*)" NONE
       Require user
    </Directory>
    

2. Replace all of the “nagiosadmin” entries with “*” in /etc/nagios/cgi.cfg. This is to prevent the error message in CGI authentication.

    It appears as though you do not have permission to view information for any of the hosts you requested...
    
    If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
    and check the authorization options in your CGI configuration file.
    
    
    [root@server ~]# grep "nagiosadmin" /etc/nagios/cgi.cfg | grep -v "#"
    
    authorized_for_system_information=nagiosadmin
    authorized_for_configuration_information=nagiosadmin
    authorized_for_system_commands=nagiosadmin
    authorized_for_all_services=nagiosadmin
    authorized_for_all_hosts=nagiosadmin
    authorized_for_all_service_commands=nagiosadmin
    authorized_for_all_host_commands=nagiosadmin
    
    [root@server ~]# vi /etc/httpd/conf.d/nagios.conf
    

Replace nagiosadmin to * as below:

    authorized_for_system_information=*
    authorized_for_configuration_information=*
    authorized_for_system_commands=*
    authorized_for_all_services=*
    authorized_for_all_hosts=*
    authorized_for_all_service_commands=*
    authorized_for_all_host_commands=*
    
    [root@server ~]# grep "*" /etc/nagios/cgi.cfg | grep -v "#"
    authorized_for_system_information=*
    authorized_for_configuration_information=*
    authorized_for_system_commands=*
    authorized_for_all_services=*
    authorized_for_all_hosts=*
    authorized_for_all_service_commands=*
    authorized_for_all_host_commands=*
    

3. Restart the nagios service

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

4. Restart apache server

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

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