Skip to main content

Opensource Network Monitoring System (NAGIOS)

NAGIOS Installation Guide

This is an open source software used for network and infrastructure monitoring. Nagios will monitor servers, switches, applications and services. It alerts the IT Administrator when something went wrong and also alerts back when the issues has been rectified.
Though the steps provided here are tested in CentOS 6.4, it may work on RHEL 6.4, Scientific Linux 6.4 and other RPM based distros.
In this tutorial i am gonna to use two systems as follows

Nagios server:
Operating system: CentOS 6.4
IP Address       : 192.168.1.100/24

Nagios client:
Operating System: CentOS 6.3
IP Address       : 192.168.1.101/24

First the install the prerequisites.
[root@server ~]# yum install -y gd gd-devel httpd php gcc glibc glibc-common
By default nagios is not found in CentOS official repository, so add the EPEL repository to install nagios.
[root@server ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[root@server ~]# rpm -ivh epel-release-6-8.noarch.rpm
Now install nagios
[root@server ~]# yum install -y nagios*
Note: It is worked for me either the SELINUX or Firewall are disabled or enabled. All you need to do is allow the apache port through iptables.

Configure Nagios
Add the admin mail address in the nagios contact file to receive alerts from nagios server.
[root@server ~]# vi /etc/nagios/objects/contacts.cfg

### Line 35 - Edit the mail id ###
email                           root@localhost  ;
Edit the following lines in nagios config file
[root@server ~]# vi /etc/httpd/conf.d/nagios.conf

## Comment Lines 15 & 16 ##
#   Order allow,deny
#   Allow from all

## Uncomment and Change lines 17,18 & 19 as shown below ##
Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.1.0/24
Set nagiosadmin password
[root@server ~]# htpasswd /etc/nagios/passwd nagiosadmin
New password:
Re-type new password:
Updating password for user nagiosadmin
Start nagios and httpd services and let them to start automatically on every boot.
[root@server ~]# /etc/init.d/nagios start
Starting nagios: done.
[root@server ~]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[root@server ~]# chkconfig nagios on
[root@server ~]# chkconfig httpd on
To allow nagios server through firewall, add the following two lines in iptables config file. This will let you to access the nagios webconsole from all clients.
[root@server ~]# vi /etc/sysconfig/iptables
 -A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
 -A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
Restart iptables
[root@server ~]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
Open nagios administrator console and enter the nagiosadmin password as created before.


Click on the “Hosts” section in the left pane of the console. You will see the no of hosts to be monitored by Nagios server.



Adding clients to Nagios server
Now let us add some clients to monitor by Nagios server.
Add the EPEL repository to install “nagios-plugins” and “nrpe” packages in client systems.
[root@client ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[root@client ~]# rpm -ivh epel-release-6-8.noarch.rpm
Install “nrpe” and “nagios-plugins” packages in client systems to be monitored.
[root@client ~]# yum install -y nrpe nagios-plugins-all openssl

Configure Clients
[root@client ~]# vi /etc/nagios/nrpe.cfg
 ## Line 81 - Add the Nagios server IP ##
allowed_hosts=127.0.0.1 192.168.1.100
Start nrpe service
[root@client ~]# /etc/init.d/nrpe start
Starting nrpe:                                             [  OK  ]
[root@client ~]# chkconfig nrpe on
To add the clients to be monitored through nagios server, open the “nagios.cfg” file in nagios server and uncomment the following lines.
[root@server ~]# vi /etc/nagios/nagios.cfg
## Line 52 - Uncomment ##
cfg_dir=/etc/nagios/servers
Create a directory called “servers” under “/etc/nagios/”.
[root@server ~]# mkdir /etc/nagios/servers
Create config file to the client to be monitored.
[root@server ~]# vi /etc/nagios/servers/clients.cfg
define host{

use                             linux-server

host_name                       client

alias                           client

address                         192.168.1.101

max_check_attempts              5

check_period                    24x7

notification_interval           30

notification_period             24x7

}
Restart nagios service.
[root@server ~]# /etc/init.d/nagios restart
 Running configuration check...done.
 Stopping nagios: .done.
 Starting nagios: done.
Now open the nagios admin console in the browser and navigate to “hosts” section in the left pane. You will see the newly added client will be visible there. Click on the host to see if there is anything wrong or alerts.




Now you can monitor the clients (hosts) as many as you added in the “clients.cfg” file. 



Comments

Popular posts from this blog

Links to various tools, calculators, config template etc.

Below are the links to various tools, calculators, config template etc. I hope you guys will find it helpful – APC Datacenter Tools ACL Wildcard Mask Calculator Aircrack-ng APC Product Selectors BackTrack Linux – Penetration Testing Bandwidth Calculator Bandwidth Speed Test Tool Bandwidth VoIP Availability Check Bandwidth VoIP Test Belkin Wizards Black Box Custom Cable and Adapter Wizards Boson Free Utilities, Cisco Config Register Calculator Brad Reese music work ambience Broadband Tools Cain – Windows Based Hacking Tool CertSearch Tool – rates Cisco practice test providers CIDR Report CIDR / VLSM Supernet Calculator Cisco 827/827H/SOHO97/837 ADSL Firewall IPSec Config Cisco 827/827H/SOHO97/837 ADSL IPSec Config Cisco 827/827H/SOHO97/837 Basic Config Cisco 827/827H/837 Business Config Cisco 827, 827H, 837, SOHO97 Config Wizard Cisco 851/851W/857/857W/871/871W/877/877W Wizard

Useful site for system & network admin

https://wintelguy.com/ Site Contents: MAC / WWN Lookup RAID Calculators DWPD, TBW, GB/day Calc. TB / TiB / GB / GiB Converter Backup Calculator Virtualization Calculators IP Subnet Calculator Network Throughput File Transfer Time Calculator WAN Latency DNS Lookup IP Locator eMail Tracer WHOIS Port Database Search Password Generator Power Unit Conversion Text Tools Cost Calculators