Nagios松弛通道集成



我使用的是slack_nagios.pl脚本。Ubuntu 14.05和Nagios 4.4.5https://raw.githubusercontent.com/tinyspeck/services-examples/master/nagios.pl我有一个频道在工作,但我需要向不同的频道发送通知。在我的情况下:警告已经转到";it_ warning";并且关键警报必须转到";it_ccritical";。我创建了两组松弛通知命令,如下所示,但我只在一个通道中收到警报(警告(。就像slack不能在两个命令之间有所不同一样,尽管在";松弛";接触具有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_nertification_commands、host_notification_commances不要忘记在您定义服务的文件中添加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
}

相关内容

  • 没有找到相关文章

最新更新