我已启动并运行 Nagios Core,但找不到任何方法来为主机安排定期停机时间。例如,假设我有一个主机,它计划在每周日凌晨 1 点重新启动。我希望能够将已知的“每周日凌晨 1:00 到凌晨 1:10”的停机时间安排到 Nagios 中,但我认为这样做的唯一方法是一次一个事件。
Mar*_*ner 11
在不使用 JakePaulus 提到的 cron 解决方案的情况下,使用 Nagios 处理“停机”的典型方法是定义和使用不包括主机停机时间的时间段。例如,在你的情况下
define timeperiod {
timeperiod_name foo
sunday 00:00-1:00,1:10-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
Run Code Online (Sandbox Code Playgroud)
一种更简单的方法是采用您预先存在的 24x7 时间段并定义和排除:
define timeperiod {
name reboot
timeperiod_name reboot
sunday 1:00-1:10
}
define timeperiod {
timeperiod_name foo
use 24x7
exclude reboot
}
Run Code Online (Sandbox Code Playgroud)
您可以使用 shell 脚本执行此操作,该脚本按 cron 指定的时间表提交外部命令(将命令输出到命名管道 nagios.cmd 文件)。这是我们使用的链接。
http://exchange.nagios.org/directory/Addons/Scheduled-Downtime/Schedule-Downtime-via-cron/details