Monitoring via powershell error 'cmdname' does not exist

I have the latest ver of Icingaweb2/director/etc installed. I have no problem adding check scripts directly to my Ubuntu 18 host running icinga. I’ve been banging my head trying to get powershell scripts to run. I’ve followed many tutorials to try and get this working…
Mainly these two:


Here’s my code
zones.d/icinga2/commands.conf
object CheckCommand “powershell” {
import “plugin-check-command”
command = [
“c:\windows\system32\windowspowershell\v1.0\powershell.exe”
]
arguments += {
“-args” = {
order = 98
value = “$ps_args$”
}
“-command” = {
order = -1
value = “$ps_command$”
}
“;exit” = {
order = 99
value = “$$LASTEXITCODE”
}
}
}

zones.d/icinga2/commands.conf
object CheckCommand “server-reboot-check” {
import “plugin-check-command”
import “powershell”

vars.powershell_script = "c:\\program files\\icinga2\\sbin\\check_reboot.ps1"

}

zones.d/icinga2/service_templates.conf
template Service “TEST REBOOT” {
check_command = “powershell”
command_endpoint = host_name
vars.powershell_script = “& ‘C:\Program Files\Icinga2\sbin\check_reboot.ps1’”
}

I can run the powershell script manually with no problem. I temporarily have the ExecutionPolicy to unrestriced for testing. Nothing I seem to do works.

Any help would be greatly appreciated!

Hi,

Please post your powershell script and a screenshot from the error message. Never seen this error. Is this from icinga? from Powershell? From windows commandline?

Try to start icinga2 service as SYSTEM User for a test.

“c:\windows\system32\windowspowershell\v1.0\powershell.exe” looks not like the way its in the tutorials. In the tutorials there are double “\”

The powershell script works. I’ve already tested it. It does not matter what script I try to call. I get the same error.

Icinga2 has been set to both Network and system users. Same issue. This is happening on the Icinga2 server.

The double slashes are there. The formatting from the forum removed them.

You have defined your command objects in zones.d/icinga2/ and I’d assume you don’t have a global zone namend icinga2. If so these commands are not send to your agents, hence, they could not by executed. Your can verify using e.g.

icinga2.exe object list -n powershell

I’ve defined windows-commands as global zone and placed every additional windows command objects in there.

1 Like

I do have a global zone named icinga2 that I keep everything in. I also have tried the powershell command in the global zone. Same problem. When running the icinga2 object list, it outputs the powershell commands.
I’ve decided to add the commands using /check_nrpe to obtain the same outputs, because it just works.

I’ll try and tackle it again once I’m done populating my icinga2 installation.

Hello,

can you please share the actuall executed command from Icinga? You can do so by enabling the debug log on the Windows system for the Agent and verify that the command is executed there and how. Once we have this we can dig deeper on where the problem comes from.