Trying to integrate Nagios Core with Slack
Posted: Fri Jul 26, 2024 1:53 pm
I've got Nagios monitoring my servers via IPMI and it's working well. Now I'm trying to get it to send alerts through Slack. The instructions seem easy enough and when I run the scripts manually they do generate slack alerts. The issue is that Nagios doesn't automatically run the scripts when an alert is generated and I'm pretty sure it's because there's no slack user defined. When I try to define a user for slack the service fails to run
These are the scripts I'm using https://github.com/obaarne/Nagios2Slack ... /README.md
They are in the plugins folder /usr/local/nagios/libexec/
I also copied the slack.cfg file to /usr/local/nagios/etc/objects/ because I wasn't sure the plugins directory was the right place for it
What am I missing?
slack.cfg
Contacts.cfg
These are the scripts I'm using https://github.com/obaarne/Nagios2Slack ... /README.md
They are in the plugins folder /usr/local/nagios/libexec/
I also copied the slack.cfg file to /usr/local/nagios/etc/objects/ because I wasn't sure the plugins directory was the right place for it
What am I missing?
slack.cfg
Code: Select all
define contact {
contact_name slack
alias Slack
host_notifications_enabled 1
service_notifications_enabled 1
service_notification_period workhours
host_notification_period workhours
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
define contactgroup {
contactgroup_name systems
alias Systems
members slack
}
define command {
command_name notify-service-by-slack
command_line /usr/local/bin/slack_nagios_service $SERVICESTATE$ $HOSTNAME$ "$SERVICEDESC$" "$LONGSERVICEOUTPUT$" "$SERVICEOUTPUT$"
}
define command {
command_name notify-host-by-slack
command_line /usr/local/bin/slack_nagios_host $HOSTSTATE$ $HOSTNAME$
Contacts.cfg
Code: Select all
define contact {
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin,slack
}