DevOps - Lab 10: Creating Contact and Contact Groups
Creating Contact and Contact Groups
In Lab 10: Creating Contact and Contact Groups, participants typically focus on extending the functionality of Nagios by configuring contacts and contact groups. Contacts represent individuals or teams responsible for receiving notifications, while contact groups allow for logical grouping of these contacts. This lab involves defining contact information, such as email addresses and notification preferences, and grouping them into contact groups based on roles or responsibilities. Participants may also configure notification settings and escalation policies to ensure that the right individuals or groups receive alerts based on predefined criteria. The lab aims to provide hands-on experience in tailoring Nagios to specific organizational structures and ensuring effective communication of critical events. Successful completion of Lab 10 equips participants with the skills to customize and optimize the notification process in Nagios for efficient incident management.
Lab:
cd /usr/local/nagios/etc/objects
ls
vi contacts.cfg
###############################################################################
#
# CONTACTS
#
###############################################################################
define contact {
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email nagios@localhost
}
define contact {
contact_name ram
alias Ram Singh
use contact-rstforum
email ram@gmail.com
}
define contact {
contact_name shyam
alias Shyam Singh
use contact-rstforum
email shyam@gmail.com
}
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
define contactgroup {
contactgroup_name linuxadministrator
alias Linux Administrators
members Ram,Shyam,nagiosadmin
}
vi templates.cfg
###############################################################################
#
# CONTACT TEMPLATES
#
###############################################################################
define contact {
name contact-rstforum
service_notification_period 24x7
host_notification_period 24x7
host_notification_options d,r
service_notification_options w,c,r
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
can_submit_commands 1
retain_status_information 1
retain_nonstatus_information 1
register 0
}
###############################################################################
#
# HOST TEMPLATES
#
###############################################################################
define host {
name linux-rstforum
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_interval 240
notification_options d,r
contact_groups LinuxAdministrator
hostgroups linuxservers
icon_image linux40.png
statusmap_image linux40.png
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
notification_period 24x7
register 0
}
define host {
name windows-rstforum
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_interval 240
notification_options d,r
contact_groups WindowsAdministrator
hostgroups windowservers
icon_image win40.png
statusmap_image win40.png
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
notification_period 24x7
register 0
}
###############################################################################
#
# SERVICE TEMPLATES
#
###############################################################################
## Service template for Web Service
define service {
name webservice-rstforum
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
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
check_interval 10
retry_interval 2
contact_groups WebAdministrator
service_groups webservice
notification_options c,r
notification_interval 0
notification_period 24x7
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
flap_detection_enabled 1
flap_detection_options c
register 0
}
## Service template for all the services
define service {
name service-rstforum
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
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 5
check_interval 5
retry_interval 1
contact_groups nagiosadmins
service_groups webservice
notification_options w,c,r
notification_interval 0
notification_period 24x7
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
flap_detection_enabled 1
flap_detection_options c
register 0
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
systemctl reload nagios
vi hostgroups.cfg
define hostgroup {
hostgroup_name webservers
alias All Web Servers
members localhost
}
define hostgroup {
hostgroup_name linuxservers
alias All Linux Servers
members localhost
}
define hostgroup {
hostgroup_name windowservers
alias All Windows Servers
members localhost
}
define hostgroup {
hostgroup_name networkdevices
alias All Network Devices
members localhost
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
systemctl reload nagios