【问题标题】:Icinga2: how to define a CheckCommand the requires one of many possible parameters?Icinga2:如何定义需要许多可能参数之一的 CheckCommand?
【发布时间】:2016-08-27 14:04:55
【问题描述】:

我在 Icinga2 中定义了一个 CheckCommand,如下所示:

object CheckCommand "foo" {
    import "plugin-check-command"
    command = [ "/opt/my_plugins/check_foo" ]

    arguments = {
        "-a" = {
            value = "$foo_a$"
            description = "Parameter A"
        }
        "-b" = {
            value = "$foo_b$"
            description = "Parameter B"
        }

    vars.foo_a = "$a$"
    vars.foo_b = "$b$"
}

该命令需要 a 或 b 或两者都需要,但如果它没有获得这些参数中的至少一个,它将无法运行。我想在Icinga2命令定义中表达这个要求,可以吗?

【问题讨论】:

  • 请发布服务配置以获得更多详细信息!

标签: plugins monitoring icinga


【解决方案1】:

注意:这适用于 NRPE 远程插件执行

自定义插件也有同样的问题。

通常 Icinga 会执行这样的命令

'/usr/local/nagios/libexec/check_nrpe' '-p' '56666' '-H' '10.104.16.214' \
'-a' '80' '90' '-c' 'nrpe_check_network_interface' 

这将导致问题,在解析此参数时,我们的插件将收到无效参数。可能在bashshell 中,我们使用shift 转到下一个可能导致问题的参数。

Icinga2 在 Checkcommand 中提供了更多选项,例如排序。

object CheckCommand "foo" {
    import "plugin-check-command"
    command = [ "/opt/my_plugins/check_foo" ]

    arguments = {
// If you need you can give this also
        "-H" = {
           value="$host$"
           order=0
        }
        "-a" = {
            value = "$foo_a$"
            description = "Parameter A"
            order = 1
        }
        "-b" = {
            value = "$foo_b$"
            description = "Parameter B"
            order = 2
        }

//No need to give vars here since it will come from service trigger part as macro.
}

不确定,试试这个!这可能会有所帮助。

【讨论】:

    猜你喜欢
    • 2015-07-15
    • 2015-10-28
    • 1970-01-01
    • 2019-06-22
    • 2014-06-16
    • 1970-01-01
    • 1970-01-01
    • 2015-04-17
    • 1970-01-01
    相关资源
    最近更新 更多