This third part in our Nagwin series focuses on configuring Nagios contacts and notifications for server status.

What’s better than being able to check on server health status through the Nagios monitoring views? Having Nagios notify you of server health status automatically! If you have ever had a server fail, shut down, or hang—only to learn about it later from disgruntled users—you’ll understand why this feature is so valuable.

Creating and Managing Contacts ^

Nagios can notify you of certain changes or issues in server configuration that may occur. Sometimes you want different alerts sent to different email addresses. For example, you may want to send alerts about a database server’s health to the DBA, and send all other alerts to the systems administrator. To define a single contact, navigate to your ICW root and go to folder /etc/nagios/nagwin. Open the contacts.cfg file in your favorite text editor. Let’s get started on defining contacts. A contact definition has the following form:

define contact {   
contact_name           systems_admin_1; short name of contact
usegeneric-contact     default contact template
alias                  Johnny Bernard Doe; full name
email                  jdoe@mycompany.com; email address
}

The “use” directive informs Nagios of which contact you would like to use. For now, use the default generic-contact option; we will explore contact templates in a bit.

Once you create several contacts, you may want to group them together, like you would with an email alias. Suppose we have four contacts: two admins and two DBAs. We might want to create two contact groups: sysadmins and dbadmins.

define contactgroup {    
contactgroup_name sysadmins;                 system alias
alias Systems Administrators;                full name of alias
members systems_admin_1,systems_admin_2;     comma separated list
}
define contactgroup {
contactgroup_name                            dbadmins;
alias                                        Database Administrators;
members                                      dba_1,dba_2;
}

Configuring Notifications ^

Nagios allows the administrator to configure notifications at different levels of granularity, including, but not limited to:

  • Who is being notified
  • Type of notification event (host status vs. service)
  • How severe the event is (from service flapping to host downtime)
  • When the event occurs

Notification options are defined in the templates.cfg file using host, service, and contact template directives. You can find an exhaustive list of directives with explanations here, but let’s start out by exploring some simplistic templates and directives.

Contact Templates ^

Contact templates allow us to define shared notification attributes for different contacts. Some contact template directives include:

  • service_notification_period: When the contact can receive service notifications
  • host_notification_period: When the contact can receive host notifications
  • service_notification_options: What kinds of service notifications the contact receives
  • host_notification_options: What kinds of host notifications the contact receives
  • service_notification_commands: How service notifications are handled
  • host_notification_commands: How host notifications are handled

We can put together an “admin” contact that receives only host notifications on a 24x7 basis and for all types of notification events:

define contact {    
name                             generic-admin-contact;
service_notifications_enabled    0; don’t enable service notes    
host_notifications_enabled       1;    
host_notification_options        d,u,r,f,s; all   
host_notification_commands       notify-host-by-email; send email
register                         0; because this is a template
}

Note that we can also define these options on a “per contact” basis; the only difference is that these directives would be specified in the contacts.cfg definition for that contact rather than in the templates.cfg contact template definition.

Host Templates ^

Host templates enable administrators to define some shared notification options for different host templates. Consider the default Windows Server template. By now, most of the directives should be fairly self-evident because they are so similar to the contact template directives:

define host {
name                   windows-server; alias
use                    generic-host; base template definition
check_period           24 x 7;
check_interval         5;
retry_interval         1;
max_check_attempts     10;
check_command          heck-host-alive; typically use this notification_period
notification_interval  30;
notification_options   d,3;
contact_groups         admins;
hostgroups             windows-servers;
icon_image             win40.png
register               0; because it’s a template
}

Imagine we wanted to create a Windows DB server template that had all of the attributes of the Windows Server template, with two exceptions: you want notifications to be pushed to only those in the dbadmins group, and you want to change the notification options to include all states. You would add the following definition:

define host {
name                   db-windows-server; new name
use                    windows-server; base template
notification_options   d,r,u,f,s; new options
contact_groups         dbadmins; new group to notify
}

Service Templates ^

Service templates allow you to configure how services will be handled with regard to notifications. We will not be covering these directives in the interest of your time, but they are explained in several other guides online.

End Result ^

Once you have configured your contacts, contact groups, and notification templates to your liking, restart the Nagwin_Nagios service in services.msc. Upon restart, your configuration will kick in. You can verify any contacts you’ve created in the Configuration -> Contacts section of the Nagios web administration interface.

Notifications and Custom Commands in Nagwin-Nrpe

0 Comments

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2022

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account