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 とカウンターを使用した経験のある人はいますか?

一重/二重引用符の問題を解決するには?

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 に答える