Icinga2:在主機/服務關閉時發送電子郵件

Icinga2:在主機/服務關閉時發送電子郵件

我使用 icingaweb2 安裝並配置了 Icinga2。

我新增了一個帶有測試服務的測試主機:我們將其稱為「example.com」。

這是測試主機:

/etc/icinga2/conf.d/hosts/example-com:

object Host "example-com" {
        //Importiert die generische Host-Vorlage aus der template.conf
        import "generic-host"
        //IPv4 Adresse
        address = "2xx.2xx.2xx.2xx"

        //Angabe des Betriebssystemtyps
        vars.os = "Linux OS"
        vars.sla = "24x7"
}

好的,然後我們就有了服務配置:

/etc/icinga2/conf.d/hosts/example-com/http.conf

object Service "http" {
    import "generic-service"
    host_name = "example-com"
    check_command = "http"
    vars.sla = "24x7"
}

當然我在/etc/icinga2/conf.d/users.conf中新增了一個新的使用者群組

/**
 * The example user 'icingaadmin' and the example
 * group 'icingaadmins'.
 */

object User "icingaadmin" {
  import "generic-user"

  display_name = "Icinga 2 Admin"
  groups = [ "icingaadmins", "linux-admins" ]

  email = "[email protected]"
}

object UserGroup "icingaadmins" {
  display_name = "Icinga 2 Admin Group"
}

object UserGroup "linux-admins" {
  display_name = "Linux-Administrators"
}

現在我想我必須將 contact_groups 新增到主機。但如果我這樣做,配置檢查就會失敗:-(

感謝您的幫助 :-)

答案1

您沒有定義任何引用主機/服務對象並連結到使用者和通知命令的通知對象。

conf.d/notifications.conf 中的範例設定已經提供了一個見解,儘管您應該考慮根據您的通知類型(無論是郵件、簡訊等)為主機和服務編寫自己的通知應用規則。使用應用程式通知

透過呼叫驗證新增的通知對象:

icinga2 object list --type Notification 

配置驗證後。

答案2

相關內容