【问题标题】:Nagios: How to check service three times a dayNagios:如何每天检查 3 次服务
【发布时间】:2019-08-12 17:27:10
【问题描述】:

我需要每天在固定时间检查 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 它说 “当 Nagios Core 尝试重新安排主机或服务检查时,它会确保下一次检查在定义的时间段内的有效时间范围内。如果没有,Nagios Core 将调整下一次检查时间以与指定时间段内的下一个“有效”时间。”

但问题是这并没有发生。

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

+--------------+--------------+-----------------+-----------------+
|    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 次服务?

谢谢!

【问题讨论】:

    标签: nagios


    【解决方案1】:

    "当 Nagios Core 尝试重新安排主机或服务检查时,它会确保下一次检查在定义的时间段内的有效时间范围内。如果没有,Nagios Core 将调整下一次检查检查时间是否与指定时间段内的下一个“有效”时间一致。”

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

    我需要每天在固定时间检查 3 次服务。

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

    • 我会将此检查作为 cron 作业运行,并将检查结果作为 passive check command 发送给 Nagios。这样,您就可以确定检查将始终按时运行。
    • 然后我会配置一个freshness_threshold 以确保这个被动服务最近确实打电话回家。
    • 我还将配置一个check_command,它为服务可能没有新结果做准备,即只有在没有收到服务检查时才执行的东西——也许是一个重新运行检查并通知的脚本我不知何故。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 2017-08-29
      • 1970-01-01
      • 2015-12-28
      • 1970-01-01
      相关资源
      最近更新 更多