Monday, January 16, 2006

Step 6 - Part 3 - Editing Object Configuration files

In these Examples I will just Explain how I Configured some services running in my localhost for nagios.

My Hostname was - mybox.sriram.com

1) A host definition is used to define a physical server, workstation, device, etc. that resides on your network.

/usr/local/nagios/etc/hosts.cfg


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

host_name mybox.sriram.com
alias Linux-Sriram #1
address 10.10.93.220
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,u,r
}

2) A service definition is used to identify a "service" that runs on a host. The term "service" is used very loosely. It can mean an actual service that runs on the host (POP, SMTP, HTTP, etc.) or some other type of metric associated with the host (response to a ping, number of logged in users, free disk space, etc.). The different arguments to a service
definition are outlined below.

/usr/local/nagios/etc/services.cfg

# Service definition
define service{
use generic-service ; Name of service template to use
host_name mybox.sriram.com
service_description POP3
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups linux_contact_groups
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_pop
}

# Service definition
define service{
use generic-service ; Name of service template to use

host_name mybox.sriram.com
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups linux_contact_groups
notification_interval 120
notification_period 24x7
notification_options c,r
check_command check_ping!100.0,20%!500.0,60%
}


3) A contact definition is used to identify someone who should be contacted in the event of a problem on your network. The different arguments to a contact definition are described below.

/usr/local/nagios/etc/contacts.cfg

# 'nagios' contact definition

define contact{
contact_name sriram
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email sriram003@gmail.com
}

4) A time period is a list of times during various days that are considered to be "valid" times for notifications and service checks. It consists one or more time periods for each day of the week that "rotate" once the week has come to an end. Exceptions to the normal weekly time range rotations are not suported.

/usr/local/nagios/etc/timeperiods.cfg

# '24x7' timeperiod definition
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}

5)
A command definition is just that. It defines a command.
When you install Nagios-plugin it installs all the commands in
/usr/local/nagios/libexec directory

/usr/local/nagios/etc/checkcommands.cfg

For any additional commands you will need to download from net or create your own Macros.

define command{
command_name check_tcp
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$
}

Note: you don't need to edit this file unless its not mentioned in checkcommands.cfg make sure that command is available in /usr/local/nagios/libexec directory.

If you want to see if there are no errors in the configuraion file then run

#/usr/local/nagios/bin/nagios -v nagios.cfg

Please make sure you set the proper permission as listed

chown nagios.nagios /usr/local/nagios/var/rw
chmod u+rwx /usr/local/nagios/var/rw
chmod g+rwx /usr/local/nagios/var/rw
In order to force newly created files in the directory to inherit the group permissions from the directory, we need to enable the group sticky bit on the directory...

chmod g+s /usr/local/nagios/var/rw

Restart Web Server

No comments: