Creating check command with unnamed parameters

Hi!

I need to call a PowerShell-Script on a Windows-Server to perform same checks.
The script need as parameter a string, but no “key” (e.g., it must be script blah and not script --blah).

I tried so:

object CheckCommand “check_eventlog” {
import “plugin-check-command”

command = [
“C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe”,
“-command”,
“& ‘C:\Program Files\NSClient++\scripts\evtsumup3\query.ps1’”,
vars.evlog_server,
]

timeout = 180s
}

Unfortunately, it does not work and I get an error from script, that no parameter was given.

If I add

arguments = {
“evlog_server” = {
value = “$evlog_server$”
}
}

I get a more confusing error:

Host and/or global config and/or exclude file is missing.

That I cannot explain… Maybe it is so because of friday, but can someone explain me where is the error?

Thanks
Luca

OK folks!

I got it! For someone other with the same problem, here my running configuration:

object CheckCommand “check_eventlog” {
import “plugin-check-command”

command = [
“C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe”,
“-command”,
“& ‘C:\Program Files\NSClient++\scripts\evtsumup3\query.ps1’”,
vars.evlog_server
]

arguments = {
“” = “$evlog_server$”
}

timeout = 180s
}

Have a nice weekend
Luca

Thank you for posting a working example.

This is very useful for people who search the archive in future.

And, congratualtions :slight_smile:

Antony.

Any particular reason why you are not using the NSClient, which seems to be installed, to run the script?

For the “powershell way” keep in mind that the check will exit with an OK state if the script is not present.
At least that is what I experienced with a similar check:

See my other topic Timeout exceeded with nscp-local the reason I tried to rewrite the check directly in Icinga…
BTW: I think, if I already have Icinga working on the server, another check program is waste, so I’m trying to rewrite all remaining checks that currently use NSClient++.

Regards
Luca