Nagios 松弛通道集成
Nagios slack channel integration
我正在使用 slack_nagios.pl 脚本。 Ubuntu 14.05 和 Nagios 4.4.5 https://raw.githubusercontent.com/tinyspeck/services-examples/master/nagios.pl
我有一个频道在工作,但我需要向不同的频道发送通知。在我的例子中:警告必须转到“it_warning”,严重警报必须转到“it_critical”。我创建了 2 组松弛通知命令,如下所示,但我总是只在一个频道中收到警报(警告)。就像 slack 不能区分这两个命令,尽管在“slack”联系人的 service_notification_options 部分有 w,r 并且在“slack_critical" 有 c,r.
没有收到错误,单独测试通道工作正常。
你能帮助我或指出正确的方向吗?
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
define contact {
contact_name slack_critical
alias Slack_critical
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-service-critical-by-slack
host_notification_commands notify-host-critical-by-slack
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members slack,nagiosadmin,slack_critical
}
define command {
command_name notify-service-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-warnings -field HOSTALIAS="$HOSTNAME$" -field SERVICEDESC="$SERVICEDESC$" -field SERVICESTATE="$SERVICESTATE$$
}
define command {
command_name notify-host-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-warnings -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field$
}
define command {
command_name notify-service-critical-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-critical -field HOSTALIAS="$HOSTNAME$" -field SERVICEDESC="$SERVICEDESC$" -field SERVICESTATE="$SERVICESTATE$$
}
define command {
command_name notify-host-critical-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-critical -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field$
}
我找到了解决办法。这里是将警告警报配置为发送到特定频道并将严重警报发送到另一个频道的步骤。
您必须使用联系人、组和命令创建 2 个单独的文件,如下所示,更改频道,service_notification_options、service_notification_commands、host_notification_commands
不要忘记在您定义服务的文件中添加 contact_groups(将是 2)。可以的话请给我点个赞。谢谢!
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin,slack
}
define command {
command_name notify-service-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-alerts-test -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$"
}
define command {
command_name notify-host-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-alerts-test -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$"
}
define service {
name generic-service
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
check_interval 10
retry_interval 2
contact_groups admins,admins_critical
notification_interval 60
notification_period 24x7
}
我正在使用 slack_nagios.pl 脚本。 Ubuntu 14.05 和 Nagios 4.4.5 https://raw.githubusercontent.com/tinyspeck/services-examples/master/nagios.pl 我有一个频道在工作,但我需要向不同的频道发送通知。在我的例子中:警告必须转到“it_warning”,严重警报必须转到“it_critical”。我创建了 2 组松弛通知命令,如下所示,但我总是只在一个频道中收到警报(警告)。就像 slack 不能区分这两个命令,尽管在“slack”联系人的 service_notification_options 部分有 w,r 并且在“slack_critical" 有 c,r.
没有收到错误,单独测试通道工作正常。 你能帮助我或指出正确的方向吗?
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
define contact {
contact_name slack_critical
alias Slack_critical
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-service-critical-by-slack
host_notification_commands notify-host-critical-by-slack
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members slack,nagiosadmin,slack_critical
}
define command {
command_name notify-service-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-warnings -field HOSTALIAS="$HOSTNAME$" -field SERVICEDESC="$SERVICEDESC$" -field SERVICESTATE="$SERVICESTATE$$
}
define command {
command_name notify-host-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-warnings -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field$
}
define command {
command_name notify-service-critical-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-critical -field HOSTALIAS="$HOSTNAME$" -field SERVICEDESC="$SERVICEDESC$" -field SERVICESTATE="$SERVICESTATE$$
}
define command {
command_name notify-host-critical-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-critical -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field$
}
我找到了解决办法。这里是将警告警报配置为发送到特定频道并将严重警报发送到另一个频道的步骤。
您必须使用联系人、组和命令创建 2 个单独的文件,如下所示,更改频道,service_notification_options、service_notification_commands、host_notification_commands 不要忘记在您定义服务的文件中添加 contact_groups(将是 2)。可以的话请给我点个赞。谢谢!
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin,slack
}
define command {
command_name notify-service-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-alerts-test -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$"
}
define command {
command_name notify-host-by-slack
command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#it-alerts-test -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$"
}
define service {
name generic-service
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
check_interval 10
retry_interval 2
contact_groups admins,admins_critical
notification_interval 60
notification_period 24x7
}