Nagios: Difference between revisions

Content added Content deleted
Line 198: Line 198:


= Slack Notifications =
= Slack Notifications =

{{UC}}
wget https://github.com/obaarne/Nagios2Slack/archive/master.zip
Refer: https://github.com/obaarne/Nagios2Slack/archive/master.zip

sudo nano /etc/nagios3/commands.cfg

<pre>
# 'notify-host-by-slack' command definition
define command {
command_name notify-host-by-slack
command_line /usr/local/bin/nagios_slack_host_alert.py -nt "$NOTIFICATIONTYPE$" -ha "$HOSTALIAS$" -hs "$HOSTSTATE$" -had "$HOSTADDRESS$" -ho "$HOSTOUTPUT$"
}

# 'notify-service-by-slack' command definition
define command {
command_name notify-service-by-slack
command_line /usr/local/bin/nagios_slack_service_alert.py -nt "$NOTIFICATIONTYPE$" -ha "$HOSTALIAS$" -sd "$SERVICEDESC$" -ss "$SERVICESTATE$" -had "$HOSTADDRESS$"
}
</pre>


sudo nano /etc/nagios3/conf.d/contacts_nagios2.cfg
<pre>
define contact{
contact_name root
alias Root
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
email root@localhost
}
</pre>



sudo nano /usr/local/bin/nagios_slack_service_alert.py


sudo nano /usr/local/bin/nagios_slack_host_alert.py


sudo chown nagios:nagios /usr/local/bin/nagios_slack_service_alert.py
sudo chown nagios:nagios /usr/local/bin/nagios_slack_host_alert.py
sudo chmod +x /usr/local/bin/nagios_slack_service_alert.py
sudo chmod +x /usr/local/bin/nagios_slack_host_alert.py