1

您好,如何进行这样的检查:

/usr/lib/nagios/plugins/check_nt -H 192.168.110.130 -p 12489 -s ****** -v COUNTER -l "\\Paging File(_Total)\\% Usage","Paging File usage is %.2f %%" -w 60 -c 90

我的实际检查命令如下所示:

object CheckCommand "check_windows_pagefile" {
    import "plugin-check-command"
    import "ipv4-or-ipv6"

    command = [ PluginDir + "/check_nt" ]

    arguments = {
        "-H" = "$component_ip$"
        "-p" = "12489"
        "-s" = "$nsclient_password$"
        "-v" = "COUNTER"
        "-l" = "\"\\\\Paging File(_Total)\\\\% Usage\",\"Paging File usage is %.2f %%\""
        "-w" = "60"
        "-c" = "90"
    }
}

但这让我只有“NSClient - 错误:命令返回无效:check_pdh”

但是,如果我执行第一个命令 bash 它可以工作。

这是 icinga2 的日志:

'/usr/lib/nagios/plugins/check_nt' '-H' '192.168.110.130' '-c' '90' '-l' '"\\Paging File(_Total)\\% Usage","Paging File usage is %.2f %%"' '-p' '12489' '-s' '******' '-v' 'COUNTER' '-w' '60'

这也不起作用:

'/usr/lib/nagios/plugins/check_nt' '-H' '192.168.110.130' '-c' '90' '-l' '\\Paging File(_Total)\\% Usage','Paging File usage is %.2f %%' '-p' '12489' '-s' '******' '-v' 'COUNTER' '-w' '60'

只有这样有效:

'/usr/lib/nagios/plugins/check_nt' '-H' '192.168.110.130' '-c' '90' '-l' "\\Paging File(_Total)\\% Usage","Paging File usage is %.2f %%" '-p' '12489' '-s' '******' '-v' 'COUNTER' '-w' '60'

有人在 check_nt 插件上使用 icinga2 和 counter 的经验吗?

如何解决单/双引号问题?

4

1 回答 1

2

首先,我发现没有解决方案可以轻松禁用 icinga 默认引用。

但是有2个解决方案。

1.)丑陋的。

不要使用“参数”并将命令构建为您自己的字符串。

object CheckCommand "check_windows_pagefile" {
    import "plugin-check-command"
    import "ipv4-or-ipv6"

    command = PluginDir + "/check_nt -l \"\\Paging File(_Total)\\% Usage\",\"Paging File usage is %.2f %%\" -H $component_ip$ -p 12489 -s $component_eav_nsclient_password$ -v COUNTER -w 60 -c 90"

} 

2.) 使用自定义参数处理程序。

template CheckCommand "command-without-quotes-from-vars" {
    command = {{
        var command = macro("$command$");
        for (key => value in macro("$arguments$")) {
            command += " " + key + " " + macro(value)
        }

        return command
    }}
}

object CheckCommand "check_windows_pagefile" {
    import "plugin-check-command"
    import "ipv4-or-ipv6"
    import "command-without-quotes-from-vars"

    vars.command = PluginDir + "/check_nt"

    vars.arguments = {
        "-H" = "$component_ip$"
        "-p" = "12489"
        "-s" = "$component_eav_nsclient_password$"
        "-v" = "COUNTER"
        "-l" = "\"\\Paging File(_Total)\\% Usage\",\"Paging File usage is %.2f %%\""
        "-w" = "60"
        "-c" = "90"
    }
} 
于 2015-12-17T09:21:27.803 回答