ONLamp.com
oreilly.comSafari Books Online.Conferences.

advertisement


Nagios, Part 2

by Oktay Altunergil
09/26/2002

In the first part of this article we've seen what Nagios is and how we can install Nagios and its plugins. We also have briefly looked at what configuration files are necessary and how to install the sample configuration files. Now we will take a look at each configuration file one by one and configure one host 'example.com' and two services on it 'http' and 'ping' to be monitored. If something goes wrong with these services, two users 'oktay' and 'verty' will be notified.

Configuring Monitoring

We first need to add our host definition and configure some options for that host. You can add as many hosts as you like, but we will stick with one host for simplicity.

Contents of hosts.cfg

# Generic host definition template
define host{
 # The name of this host template - referenced i
 name                            generic-host    
 n other host definitions, used for template recursion/resolution
 # Host notifications are enabled
 notifications_enabled           1     
 # Host event handler is enabled   
 event_handler_enabled           1        
 # Flap detection is enabled  
 flap_detection_enabled          1     
 # Process performance data
 process_perf_data               1
 # Retain status information across program restarts       
 retain_status_information       1   
 # Retain non-status information across program restarts    
 retain_nonstatus_information    1       
 # DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST,
 # JUST A TEMPLATE!
 register                        0        
}


# Host Definition

define host{
 # Name of host template to use
 use                     generic-host             

 host_name               example.com
 alias                   An Example Domain
 address                 www.example.com
 check_command           check-host-alive
 max_check_attempts      10
 notification_interval   120
 notification_period     24x7
 notification_options    d,u,r
}

The first host defined is not a real host but a template which other host definitions are derived from. This mechanism can be seen in other configuration files also and makes configuration based on a predefined set of defaults a breeze.

With this setup we are monitoring only one host , 'www.example.com' to see if it is alive. The 'host_name' parameter is important because this server will be referred to by this name from the other configuration files.

Now we need to add this host to a hostgroup. Even though we will keep the configuration simple by defining a single host, we still have to associate it with a group so that the application knows which contact group (see below) to send notifications to.

Contents of hostgroups.cfg

define hostgroup{
        hostgroup_name  flcd-servers
 alias           The Free Linux CD Project Servers
 contact_groups  flcd-admins
 members         example.com
}

Above, we have defined a new hostgroup and associate the 'flcd-admins' contact group with it. Now let's look into the contactgroup settings.

Contents of contactgroups.cfg

define contactgroup{
 contactgroup_name       flcd-admins
 alias                   FreeLinuxCD.org Admins
 members                 oktay, verty
}

We have defined the contact group 'flcd-admins' and added two members 'oktay' and 'verty' to this group. This configuration ensures that both users will be notified when something goes wrong with a server that 'flcd-admins' is responsible for. (Individual notification preferences can override this). The next step is to set the contact information and notification preferences for these users.

Pages: 1, 2, 3

Next Pagearrow





Sponsored by: