Linux

如何在午夜設置 icinga2 停機時間

  • August 19, 2019

我們的備份在 22:00 到第二天大約 05:00 之間執行。我無法弄清楚如何使用 icinga2 中的“應用 ScheduledDowntime”(opensuse 42.1 上的 r2.4.1-1)在計劃的停機時間內設置它。

只是設置 22:00-05:00 會給我一個錯誤:

無效的時間範圍定義“22:00-05:00”:時間段在開始之前結束

目前機制使用服務變數backup_downtime,它反過來在不為空時觸發“應用”規則:

apply ScheduledDowntime "backup-downtime" to Service {
 author = "icingaadmin"
 comment = "Scheduled downtime for backup"

 ranges = {
   monday = service.vars.backup_downtime
   tuesday = service.vars.backup_downtime
   wednesday = service.vars.backup_downtime
   thursday = service.vars.backup_downtime
   friday = service.vars.backup_downtime
   saturday = service.vars.backup_downtime
   sunday = service.vars.backup_downtime
 }

 assign where service.vars.backup_downtime != ""
}

有人出主意嗎?謝謝

您可以分配該service.vars.backup_downtime"22:00-24:00,00:00-05:00",以便您在第二天 22:00 到 05:00 之間獲得停機時間。

IE。服務定義將是:

apply Service "foo" {
 display_name = "foo process"
 import "generic-service"
 check_command = "foo-process"
 command_endpoint = host.address
 vars.backup_downtime = "22:00-24:00,00:00-05:00"
 assign where host.vars.type == "bar"
}

停機時間也可以定義為整個午夜的一段較長時間,例如凌晨 5 點是 24+5 = 29:00:

vars.backup_downtime = "22:00-29:00"

引用自:https://serverfault.com/questions/754275