Check by powershell


Icinga agent installation causing memory leak in our windows server and only very few checks are running on the server

So I am trying check_by powershell in director method
Unfortunately i am not getting correct details how to configure it in director way.commands are genereted in external commands sections also I am getting the output from linux cmd line.
anyone tried the same ?

Thanks in advance

Hi @krishna

Are you using the powershell framework? You can import the commands into the director.

Kind regards

Hi @ritzgu,

Powershell framework i am using

Commands are also imported through Director basket configuration

Still confused how i can declare the variable as mentioned in the example Powershell

I may have misread your question. Are you trying to check via WinRM or the icinga2 agent?

Hi @ritzgu yes I am trying check via winrm


I think the commands imported via the director basket require a local agent to execute the checks. What i think you want to do is check the windows host remotely via check_by_powershell and WinRM. I guess you have to create your own command definition for this.


I have created my own command definitions
Like checking cpu load in the external command section

But dont know how to do it in director way
What are the variables need to declared

Would have been good if they provide some more example


I tried to recreate the example command. Instead of using a dictionary for the --icingacmd, i just used a string.
Then I created another command for the specific check which imports the above command. The arguments can be directly added to the command string.
Idea from here

Kind regards

1 Like


Could you please show me the preview of the command and service

what is the argument you created for powershell_command?


# preview of powershell template
object CheckCommand "by_powershell" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_by_powershell" ]
    arguments += {
        "--auth" = "$powershell_auth$"
        "--ca" = "$powershell_ca$"
        "--cert" = "$powershell_cert$"
        "--cmd" = "$powershell_cmd$"
        "--icingacmd" = "$powershell_command$"
        "--insecure" = {
            set_if = "$powershell_insecure$"
        "--key" = "$powershell_key$"
        "--no-tls" = {
            set_if = "$powershell_no_tls$"
        "--password" = "$powershell_password$"
        "--sshhost" = "$powershell_sshhost$"
        "--sshpassword" = "$powershell_sshpassword$"
        "--sshuser" = "$powershell_sshuser$"
        "--user" = "$powershell_user$"
        "-H" = "$powershell_host$"
        "-p" = "$powershell_port$"
    vars.powershell_insecure = true
// preview of specific cpu command
object CheckCommand "by_powershell_cpu" {
    import "plugin-check-command"
    import "by_powershell"

    vars.powershell_command = "Invoke-IcingaCheckCPU -Warning $powershell_cpu_warning$ -Critical $powershell_cpu_critical$"
    vars.powershell_cpu_critical = "90"
    vars.powershell_cpu_warning = "80"
    vars.powershell_host = "$address$"

In the director you have to add the custom fields for the thresholds to the command.
The resolved service command:

// preview of service
apply Service "test-cpu" {
    import "agent-service"

    check_command = "by_powershell_cpu"
    assign where host.vars.os == "windows"
    vars.powershell_cpu_critical = "90"
    vars.powershell_cpu_warning = "75"
    vars.powershell_password = "some_password"
    vars.powershell_port = "5986"
    vars.powershell_user = "some_user"

    import DirectorOverrideTemplate

Thanks for your input

Let me check it and try to configure it
So it means for each check we need to create respective commands?

I don’t know if there’s a better way now but i had the same problem in the past with by_ssh and found this discussion to be useful. Maybe this will change with the support for dictionaries.

Ok thanks for your valuable suggestion and your time

Thanks and Regards