-
Notifications
You must be signed in to change notification settings - Fork 4
Integrating hume with Nagios
If you are a bit tired of email notifications, you can use hume to route your service and host notifications to something better like Slack. For this to work you need hume version >= 1.2.22:
$ hume --version
HumeClient v1.2.22 by Buanzo
The idea is to define two new commands (usually to commands.cfg in /etc/nagios3 - YMMV):
define command {
command_name notify-service-by-hume
command_line /usr/local/bin/hume --hostname "$HOSTNAME$" -L "$SERVICESTATE$" -t "$SERVICEDESC$" "$NOTIFICATIONTYPE$ -- Service has been in $SERVICESTATE$ for $SERVICEDURATION$ - Service Check Output (if any): $LONGSERVICEOUTPUT$" 2>/tmp/service.log
}
define command {
command_name notify-host-by-hume
command_line /usr/local/bin/hume --hostname "$HOSTNAME$" -L critical -t NAGIOS_HOST_NOTIFICATION "Host State: $HOSTSTATE$ - Duration: $HOSTDURATION$" 2>/tmp/host.log
}
As you can see, there is a stderr redirection at the end of each command_line: Once you know all is working, you can delete that and reload nagios3.
Then you need to enable the usage of those commands for service and host notifications.
You can do this either via contacts configuration, or globally. For the global option, edit your nagios.cfg file, and search/modify/add these keywords:
global_host_event_handler=notify-host-by-hume
global_service_event_handler=notify-service-by-hume
If you prefer to use a contact, use something like this, and remember to set services and hosts to use it:
define contact {
contact_name hume
alias Hume Dispatcher
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-hume
host_notification_commands notify-host-by-hume
}
Enjoy!