Nagios triggers

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:
Modify contact_name, alias, and email
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
}

The service_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 states
*u: Notify on UNKNOWN service states
*c: Notify on CRITICAL service states
*r: Notify on service RECOVERY (OK states)
*f: Notify when the service starts and stops FLAPPING
*n (none): Do not notify the contact on any type of service notifications

The host_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 states
*u: Notify on UNREACHABLE host states
*r: Notify on host RECOVERY (UP states)
*f: Notify when the host starts and stops FLAPPING
*s: Send notifications when host or service scheduled downtime starts and ends
*n (none): Do not notify the contact on any type of host notifications.

Note
By default, contact and a contact group are defined for administrators in contacts.cfg and all the services and hosts will notify the administrators. Add suitable email id for administrator in contacts.cfg file.

To add a group to which the mail needs 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:
Add contact_groups name and contacts 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 in notify-service-by-email and notify-host-by-emailcommand 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





Recent Comments

No comments

Leave a Comment