17.4. Monitoring Notifications
17.4.1. Configuring Nagios Server to Send Mail Notifications
- In the
/etc/nagios/gluster/gluster-contacts.cfg
file, add contacts to send mail in the format shown below:Modifycontact_name
,alias
, andemail
.define contact { contact_name Contact1 alias ContactNameAlias email email-address service_notification_period 24x7 service_notification_options w,u,c,r,f,s service_notification_commands notify-service-by-email host_notification_period 24x7 host_notification_options d,u,r,f,s host_notification_commands notify-host-by-email } define contact { contact_name Contact2 alias ContactNameAlias2 email email-address service_notification_period 24x7 service_notification_options w,u,c,r,f,s service_notification_commands notify-service-by-email host_notification_period 24x7 host_notification_options d,u,r,f,s host_notification_commands notify-host-by-email }
Theservice_notification_options
directive is used to define the service states for which notifications can be sent out to this contact. Valid options are a combination of one or more of the following:w
: Notify on WARNING service statesu
: Notify on UNKNOWN service statesc
: Notify on CRITICAL service statesr
: Notify on service RECOVERY (OK states)f
: Notify when the service starts and stops FLAPPINGn (none)
: Do not notify the contact on any type of service notifications
Thehost_notification_options
directive is used to define the host states for which notifications can be sent out to this contact. Valid options are a combination of one or more of the following:d
: Notify on DOWN host statesu
: Notify on UNREACHABLE host statesr
: Notify on host RECOVERY (UP states)f
: Notify when the host starts and stops FLAPPINGs
: Send notifications when host or service scheduled downtime starts and endsn (none)
: Do not notify the contact on any type of host notifications.
Note
By default, a contact and a contact group are defined for administrators incontacts.cfg
and all the services and hosts will notify the administrators. Add suitable email id for administrator incontacts.cfg
file. - To add a group to which the mail need to be sent, add the details as given below:
define contactgroup{ contactgroup_name Group1 alias GroupAlias members Contact1,Contact2 }
- In the
/etc/nagios/gluster/gluster-templates.cfg
file specify the contact name and contact group name for the services for which the notification need to be sent, as shown below:Addcontact_groups
name andcontacts
name.define host{ name gluster-generic-host use linux-server notifications_enabled 1 notification_period 24x7 notification_interval 120 notification_options d,u,r,f,s register 0 contact_groups Group1 contacts Contact1,Contact2 } define service { name gluster-service use generic-service notifications_enabled 1 notification_period 24x7 notification_options w,u,c,r,f,s notification_interval 120 register 0 _gluster_entity Service contact_groups Group1 contacts Contact1,Contact2 }
You can configure notification for individual services by editing the corresponding node configuration file. For example, to configure notification for brick service, edit the corresponding node configuration file as shown below:define service { use brick-service _VOL_NAME VolumeName __GENERATED_BY_AUTOCONFIG 1 notes Volume : VolumeName host_name RedHatStorageNodeName _BRICK_DIR brickpath service_description Brick Utilization - brickpath contact_groups Group1 contacts Contact1,Contact2 }
- To receive detailed information on every update when Cluster Auto-Config is run, edit
/etc/nagios/objects/commands.cfg
file add$NOTIFICATIONCOMMENT$\n
after$SERVICEOUTPUT$\n
option innotify-service-by-email
andnotify-host-by-email
command definition as shown below:# 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n $NOTIFICATIONCOMMENT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ }
- Restart the Nagios server using the following command:
# service nagios restart
The Nagios server sends notifications during status changes to the mail addresses specified in the file.
Note
- By default, the system ensures three occurences of the event before sending mail notifications.
- By default, Nagios Mail notification is sent using
/bin/mail
command. To change this, modify the definition fornotify-host-by-email
command andnotify-service-by-email
command in/etc/nagios/objects/commands.cfg
file and configure the mail server accordingly. - Ensure that the mail server is setup and configured.
17.4.2. Configuring Simple Network Management Protocol (SNMP) Notification
- Log in as root user.
- In the
/etc/nagios/gluster/snmpmanagers.conf
file, specify the Host Name or IP address and community name of the SNMP managers to whom the SNMP traps need to be sent as shown below:HostName-or-IP-address public
In the/etc/nagios/gluster/gluster-contacts.cfg
file specify the contacts name as +snmp as shown below:define contact { contact_name snmp alias Snmp Traps email admin@ovirt.com service_notification_period 24x7 service_notification_options w,u,c,r,f,s service_notification_commands gluster-notify-service-by-snmp host_notification_period 24x7 host_notification_options d,u,r,f,s host_notification_commands gluster-notify-host-by-snmp }
You can download the required Management Information Base (MIB) files from the URLs given below: - Restart Nagios using the following command:
# service nagios restart