且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

icinga2对特定服务设置专门发邮件策略

更新时间:2022-10-02 21:04:21


icinga2对特定服务设置专门发邮件策略(如mysql、web等):


# vi /etc/icinga2/conf.d/timeperiods.conf (也可以新建个TimePeriod)


object TimePeriod "9to5" {

  import "legacy-timeperiod"


  display_name = "Icinga 2 9to5 TimePeriod"

  ranges = {

    "monday"  = "08:00-20:00"

    "tuesday"  = "08:00-20:00"

    "wednesday" = "08:00-20:00"

    "thursday"  = "08:00-20:00"

    "friday"  = "08:00-20:00"

  }

}

:wq


# vi /etc/icinga2/conf.d/services.conf 

 


apply Service "check_hudson" {

  import "generic-service"

  check_command = "check-http"

  vars.url="http://$address$:8080/jenkins"

  vars.port="8080"

  vars.perf = true

  assign where host.vars.os == "hudson"

}



apply Notification "mail" to Service {

  import "mail-service-notification-2"

  command = "mail-service-notification"

  users = [ "webicinga" ]

  assign where service.name == "check_hudson"

}

:wq



# service icinga2 restart

本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1960088如需转载请自行联系原作者


yangzhimingg