1

Hello how is it possbile to perform a check like this:

/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

My actual check command looks like this:

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"
    }
}

But this gets me only "NSClient - ERROR: Invalid return from command: check_pdh"

But if i perform the first command an bash it works.

This is what icinga2 log:

'/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'

This is also not working:

'/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'

Only this is working:

'/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'

Has someone experience with icinga2 and counter at the check_nt plugin?

How to solve the single / double quote problem?

GreenRover
  • 1,486
  • 1
  • 14
  • 33

1 Answers1

3

First, i found no solution to easy disable the icinga default quoting.

But there are 2 solutions.

1.) The ugly one.

Dont use "arguments" and build the command as string by your own.

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.) Use a custom argument handler.

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"
    }
} 
GreenRover
  • 1,486
  • 1
  • 14
  • 33
  • i'm facing same problem, the only difference is i'm working on containerised icinga and i'm using "icinga Director pluging", I can't implement what you found. can you help ? – Chawki Aug 11 '20 at 18:26