Nagios Documentation
================================================================
Nagios Server Basic information:-
================================================================
Nagios Binaries: -/opt/nagios
Nagios server Configuration: - /etc/Nagios
Nagios data: /var/Nagios
Nagios plugins: - /opt/nagios/plugins/
User for Nagios : Nagios
Nagios user password: Nagios
Nagios group: nagioscmd
================================================================
Configuration files:-
================================================================
/etc/nagios/hosts.cfg
:- File to define host
/etc/nagios/services.cfg:-
File to define services
/etc/nagios/hostgroups.cfg:-
File to define host groups or add host
in to group
/etc/nagios/servicegroups.cfg:-
File to define service group or add service in to group
/etc/nagios/contacts.cfg:-
File to define contact and contact group
/etc/nagios/service_dependencies.cfg:-
file to define Service dependencies
/etc/nagios/escalationservices.cfg:-
File to define service escalation template
/etc/nagios/escalationhost.cfg:-
File to define host escalation template
/etc/nagios/serviceescalation/:- Directory
to define service escalation
/etc/nagios/hostescalation/
:- Directory to define host escalation
/etc/nagios/notification/notifications.cfg
: File to define notification command
===================================================================
Adding new host for
monitoring
===================================================================
- Two templates are created for Servers and network devices as core-server for server and core-network for network devices.
- To add new host in Nagios we required host name and IP address of system.
- To add host for monitoring we have to modify and append /etc/nagios/hosts.cfg at the bottom of the file define host information a:-
use core-server
host_name sandeep.domainname.com
alias sandeep
address 192.168.1.115
parents Router_Pune
statusmap_image win40.gd2
}
=====================================================================
Add new host group or
adding host in to group.
=====================================================================
we have to modify and append /etc/nagios/hostgroups.cfg this file when we required to add new
host group or to add other group into
other host group or to add host in to existing group.
define hostgroup{
hostgroup_name All_Server
alias All_Server
hostgroup_members Mumbai_Win_Server,Pune_Win_Server
members Sandeep.domainname.com,Linux05.domainname.com
}
define hostgroup{
hostgroup_name Mumbai_Win_Server
alias Mumbai_Win_Server
members File_Server01.domainname.com,AD_Pri.domainname.com
}
========================================================================
Add services in to Nagios
for monitoring.
========================================================================
- We have to modify or append /etc/nagios/services.cfg file for adding new services in to nagios or monitoring services for the host.
- Created templates for comman setting for services and latter use that template for monitoring services and adding host information to monitor services.
For example:- we have created one common template as services for all services and latter we create new separate template for each service and then use that template and add host by separated by " , " .
name services
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 10
retry_check_interval 2
contact_groups admins
notification_options w,u,c,r
# notification_interval 60
notification_period 24x7
register 0
}
For example monitoring ping for all host:-
define service{
use services,graphed-service,srv-pnp
name ping
check_command check_ping!1000.0,20%!2000.0,60%
register 0
}
define service{
use ping
service_description PING
contact_groups admins
hostgroup_name all_hosts
}
One more example for monitoring C drive :-
define service{
use services
name Disk space on c
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
register 0
}
define service{
use Disk space on c
service_description C: Drive Space
host_name File_Server01.domainname.com, AD_Pri.domainname.com, Sandeep.domainname.com
# hostgroup_name Domain Controllers
}
========================================================================
Add Service group in
to Nagios.
========================================================================
To add service group we have to modify or append /etc/nagios/servicegroups.cfg file . Service group
are same as host group only instead of hostgroup_name . We have to use servicegroup_name.
and one more thing to conceder is that when adding member syntax for this is < hostname,service_description>
define servicegroup{
servicegroup_name
dns-server
alias DNS Servers
members
DC-01.domainname.com,Dns,DC01-MUMBAI.domainname.com,Dns,
}
define servicegroup{
servicegroup_name C: Drive
alias C: Drive
members
File_Server01.domainname.com,C: Drive Space,AD_Pri.domainname.com,C:
Drive Space
}
========================================================================
Create new contact or
contact group in to Nagios.
=========================================================================
We define contact or contact group in nagios. by modify or
append /etc/nagios/contacts.cfg file.
define contact{
contact_name
sandeep
use generic-contact
alias sandeep kapadane
email sandeepk@email.com
}
define contact{
contact_name yourname
use generic-contact
alias Your Name
email yourname@email.com
}
To create contact group same like servicegroup_name and
hostgroup_name:-
define contactgroup{
contactgroup_name IT_Team_Pune
alias IT Team Pune Administrators
members sandeep,yourname
}
========================================================================
Configure Service
dependencies in Nagios.
========================================================================
We have to modify or append
/etc/nagios/service_dependencies.cfg
for configure service dependences in
nagios.
define servicedependency{
host_name File_Server01.domainname.com
service_description NSClient++ Version
dependent_host_name File_Server01.domainname.com
dependent_service_description UP TIME ,C: Drive Space,CPU Load,Memory Usage,Server Service,DNS Server Service
notification_failure_criteria o,c,w,u,p
execution_failure_criteria n
}
define servicedependency{
host_name File_Server01.domainname.com
service_description UP TIME
dependent_host_name File_Server01.domainname.com
dependent_service_description C: Drive Space,CPU Load,Memory Usage,Server Service,DNS Server Service
notification_failure_criteria o,c,w,u,p
execution_failure_criteria n
}
=========================================================================
Define service
escalation template
=========================================================================
Service escalation template will define in /etc/nagios/escalationservices.cfg file latter we use this template for every service
escalation .
# First three notification sent to every 60 min interval (one mail per 1hr in a day )
define serviceescalation{
name 1stnotification
first_notification 1
last_notification 3
notification_interval 60
register 0
}
# After 3rd notification 4th and 5th every 300 min (one mail per 5hr )
define serviceescalation{
name 2ndnotification
first_notification 4
last_notification 5
notification_interval 300
register 0
}
# After 5th notification 6th and 7th notification every 12 hr
define serviceescalation{
name 3rdnotification
first_notification 6
last_notification 7
notification_interval 720
register 0
}
# After 7th notification 8th to 14th notification every 24hr (one mail per day)
define serviceescalation{
name 4thnotification
first_notification 8
last_notification 14
notification_interval 1440
register 0
} # After 14th notification one mail every 7200 min (one mail per week) till fix the problem
define serviceescalation{
name 5thnotification
first_notification 15
last_notification 0
notification_interval 7200
register 0
}
=====================================================================
Define host
escalation template
======================================================================
Host escalation template define in
file /etc/nagios/escalationhost.cfg and it same as service escalation only we
have to change serviceeescalation with hostescalation for example:-
define hostescalation{
name 1stnotification
first_notification 1
last_notification 3
notification_interval 60
register 0
}
define hostescalation{
name 2ndnotification
first_notification 4
last_notification 5
notification_interval 300
register 0
}
========================================================================
Define service
escalation
========================================================================
To define service escalation for services we need to create
new file for each services in /etc/nagios/serviceescalation/ directory with
file extension with .cfg file for example service escalation for ping service
we have to create new file name as ping.cfg and add notification option and
contact name.
Ping.cfg”-
# For Defining service escalation nagios required at list host_name And/or hostgroup_name , contacts and/or contact_groups and service_description along with our template :-
define serviceescalation{
use 1stnotification
# host_name sandeep.domainname.com
hostgroup_name all_hosts
service_description PING
#
contact_groups admins
contacts sandeep
}
define serviceescalation{
use 2ndnotification
# host_name sandeep.domainname.com
hostgroup_name all_hosts
service_description PING
#
contact_groups admins
contacts sandeep,yourname
}
define serviceescalation{
use 3rdnotification
# host_name sandeep.domainname.com
hostgroup_name all_hosts
service_description PING
# contact_groups admins
contacts sandeep,yourname,help
}
define serviceescalation{
use 4thnotification
# host_name sandeep.domainname.com
hostgroup_name all_hosts
service_description PING
#
contact_groups admins
contacts sandeep,yourname,help
}
define serviceescalation{
use 5thnotification
# host_name sandeep.domainname.com
hostgroup_name all_hosts
service_description PING
#
contact_groups admins
contacts sandeep,yourname,help
}
========================================================================
Define host
escalation
========================================================================
Configuring host escalation is same as service escalation
just we have to create new file in /etc/nagios/hostescalation/
directory. For example host escallaion for all_host group
# For Defining host escalation nagios required at list host_name
And/or hostgroup_name , contacts and/or contact_groups along with our template :-
define hostescalation{
use 1stnotification
# host_name sandeep.domainname.com
hostgroup_name all_hosts
#
contact_groups admins
contacts sandeep
}
No comments:
Post a Comment