Sunday, March 3, 2013

How to Monitoring Linux/Unix Machines using Nagios

First define the contacts in the file /usr/local//nagios/etc/objects/contacts.cfg

define contact{

contact_name nagiosadmin

use generic-contact

alias Nagios Admin

email <enter the
notifying email ids separated by commas>

}

define contactgroup{

contactgroup_name admins

alias Nagios Administrators

members nagiosadmin

}

The notification will be sent to members
mentioned in the nagiosadmin contacts.

There are 2 ways to define services:

1.Service definition for local machine.

2.Service definition for remote host

Service
definition for local machine

Before proceeding first you need to define a
hostgroup as shown below:

define hostgroup{

hostgroup_name groupname1

members server1,server2

}

Now define a host:

define host {

use generic-host

host_name server1 ; IP address/hostname of the
machine

alias server1 ; A longer name associated
with the host

address XX.XX.XX.XX ; IP address of the host

hostgroups groupname1 ; Host groups this host is associated
with

}

Now it is the time for defining services to be monitored on
the defined host:

Service definition
for PING

define service{

use
generic-service,srv-pnp ;
Name of service template to use

hostgroup_name groupname1

service_description PING

check_command check_ping!100.0,20%!500.0,60%

contact_groups admins

}

Service definition
for website check

define service{

use
generic-service,srv-pnp

host_name server1

contact_groups admins

service_description www.your website.com

check_command check_website! www.your website.com '

}

Service definition
for remote host

Before proceeding you need to install a NRPE plugin on the
remote host.

NRPE is an addon that allows you to execute plugins
on remote Linux/Unix hosts. This is useful if you need to monitor local
resources/attributes like disk usage, CPU load, memory usage, etc. on a remote
host. Similiar functionality can be accomplished by using the check_by_ssh
plugin, although it can impose a higher CPU load on the monitoring machine -
especially if you are monitoring hundreds or thousands of hosts.
Download the NRPE plugin on the Remote Host using below URL: