Nagios:如何一天三次检查服务

Nagios: How to check service three times a day

我需要一个每天定时检查3次的服务。 检查应 运行 在 7、15 和 23 小时(当时每 8 小时一次)。

我尝试过定义一个时间段:

define timeperiod{
    timeperiod_name         three_times_a_day
    monday                  07:00-07:10, 15:00-15:10, 23:00-23:10
    tuesday                 07:00-07:10,15:00-15:10,23:00-23:10
    wednesday               07:00-07:10,15:00-15:10,23:00-23:10
    thursday                07:00-07:10,15:00-15:10,23:00-23:10
    friday                  07:00-07:10,15:00-15:10,23:00-23:10
    saturday                07:00-07:10,15:00-15:10,23:00-23:10
    sunday                  07:00-07:10,15:00-15:10,23:00-23:10
}

服务(在多个主机上)是这样的:

define service{
    use                     all_templates
    host_name               some_host
    service_description     some_service
    check_command           some_command
    check_period            three_times_a_day
    max_check_attempts      1
    check_interval          480 ; run every 8 hours
}

从这里 https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/timeperiods.html 它说 "When Nagios Core attempts to reschedule a host or service check, it will make sure that the next check falls within a valid time range within the defined timeperiod. If it doesn't, Nagios Core will adjust the next check time to coincide with the next "指定时间段内的“有效时间”。

但事实是这并没有发生。

当我检查调度队列时,我看到:

+--------------+--------------+-----------------+-----------------+
|    Host      |   Service    |   Last Check    |   Next Check    |
+--------------+--------------+-----------------+-----------------+
| some_host    | some_service | 8/12/2019 9:35  | 8/12/2019 15:01 |
| some_host_1  | some_service | 8/12/2019 7:01  | 8/12/2019 15:01 |
| some_host_2  | some_service | 8/12/2019 8:50  | 8/12/2019 15:02 |
| some_host_3  | some_service | 8/12/2019 9:30  | 8/12/2019 15:02 |
| some_host_4  | some_service | 8/12/2019 9:22  | 8/12/2019 15:02 |
| some_host_5  | some_service | 8/12/2019 7:03  | 8/12/2019 15:03 |
| some_host_6  | some_service | 8/12/2019 8:53  | 8/12/2019 15:04 |
| some_host_7  | some_service | 8/12/2019 9:58  | 8/12/2019 15:04 |
| some_host_8  | some_service | 8/12/2019 9:30  | 8/12/2019 15:04 |
| some_host_9  | some_service | 8/12/2019 7:05  | 8/12/2019 15:05 |
| some_host_10 | some_service | 8/12/2019 9:01  | 8/12/2019 15:05 |
| some_host_11 | some_service | 8/12/2019 10:02 | 8/12/2019 15:05 |
| some_host_12 | some_service | 8/12/2019 9:21  | 8/12/2019 15:05 |
| some_host_13 | some_service | 8/12/2019 7:08  | 8/12/2019 15:08 |
| some_host_14 | some_service | 8/12/2019 7:08  | 8/12/2019 15:08 |
| some_host_15 | some_service | 8/9/2019 14:49  | 8/12/2019 16:24 |
+--------------+--------------+-----------------+-----------------+

为什么在时间段外检查服务? 为什么 some_host_15 没有检查 8 月 10 日、8 月 11 日和 8 月 12 日? 怎样才能做到每天定时查看服务3次?

谢谢!

"When Nagios Core attempts to reschedule a host or service check, it will make sure that the next check falls within a valid time range within the defined timeperiod. If it doesn't, Nagios Core will adjust the next check time to coincide with the next "valid" time in the specified timeperiod."

我实际上非常确定情况不会如此,但如果您看到不同的行为,这可能是一个错误。我希望时间段和检查间隔会产生一个时间问题,导致许多检查被丢弃。不管事情应该如何工作以及 is/isn 预期的行为是什么,我都不会像这样亲自配置它。既然你这么说:

I need a service to be checked three times a day at fixed times.

如果我是你,我会这样做:

  • 我会 运行 此检查作为 cron 作业,并将检查结果作为 passive check command 发送到 Nagios。这样,您就可以确定支票总是运行准时。
  • 然后我会配置 freshness_threshold 以确保此被动服务最近确实给家里打电话。
  • 我还会配置一个 check_command 来为服务没有新结果的可能性做准备,即只有在没有收到服务检查时才执行的东西——也许是一个重新运行支票并以某种方式通知我。