Run on agent without using director

Hi All,

I am trying to monitor cpu, drives etc of a windows host where i have installed the icinga agent & PS framework. I am testing a few things without using director. So with the Icinga API i have put the windows host for monitoring. Now i have configured a command for Invoke check cpu , created a service as well for the same but i am getting - execvpe(C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) failed: No such file or directory. I know if do it via the director i have an option to select run on agent so that the check source becomes the remote host, but i am not sure where to configure this in the command or services or maybe i need to change something in zones.
Command -
object CheckCommand “Invoke-IcingaCheckCPU” {
import “PowerShell-Base”

command = [
    "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
]

arguments += {
    "-C" = {
        order = 0
        value = "exit Invoke-IcingaCheckCPU"
    }
    "-Core" = {
        order = 4
        value = "$IcingaCheckCPU_String_Core$"
    }
    "-Critical" = {
        order = 3
        value = "$IcingaCheckCPU_Object_Critical$"
    }
    "-NoPerfData" = {
        order = 99
        value = "$IcingaCheckCPU_Switchparameter_NoPerfData$"
    }
    "-Verbosity" = {
        order = 5
        value = "$IcingaCheckCPU_Int32_Verbosity$"
    }
    "-Warning" = {
        order = 2
        value = "$IcingaCheckCPU_Object_Warning$"
    }
}

vars.IcingaCheckCPU_String_Core = "*"

// vars.IcingaCheckCPU_Object_Critical = null
vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
vars.IcingaCheckCPU_Int32_Verbosity = 0
// vars.IcingaCheckCPU_Object_Warning = null
}
Service -
apply Service “check_cpu_usage” {
import “generic-service”
check_command = “Invoke-IcingaCheckCPU”

vars.IcingaCheckCPU_String_Core = "*"  // Adjust as needed for specific core(s)
//vars.IcingaCheckCPU_Object_Critical = "$null"
vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
vars.IcingaCheckCPU_Int32_Verbosity = 0
//vars.IcingaCheckCPU_Object_Warning = "$null"

assign where host.vars.os == "Windows" // Adjust this according to your host definition

Notice the check source is master

You need to add to your service definition:

command_endpoint = host.name

Can you explain why?

I am aware that this issue is old but still wanted to inquire if you could reason for your past reply.

Without command_endpoint checks are executed on an endpoint of zone to which host belongs e.g. master. With command_endpoint checks executed on that machine instead e.g. Agent.

1 Like

Thank you very much!