Check command 'Invoke-IcingaCheckCPU' does not exist

Hi,
I installed “Icinga for Windows” on my windows endpoint and setup to connect to my Icinga node.

I signed the certificate, so my windows host is able to connect to icinga server.
I created json for Invoke-IcingaCheckCPU, imported into “Directory Basket”, so I see the command inside Icinga Director, and after I configured the service to check CPU etc.

I tried to check my service on Icinga, related to the Windows Host but I obtain:
Check command ‘Invoke-IcingaCheckCPU’ does not exist

I noted on windows host, the startup log: C:\ProgramData\icinga2\var\lib\icinga2\api\zones-stage-startup.log

[2022-10-06 11:13:11 +0200] information/cli: Icinga application loader (version: v2.13.5)
[2022-10-06 11:13:11 +0200] information/cli: Loading configuration file(s).
[2022-10-06 11:13:11 +0200] critical/config: Error: Object ‘director-global’ of type ‘Zone’ re-defined: in C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf: 1:0-1:28; previous definition: in C:/ProgramData/icinga2/etc/icinga2/zones.conf: 17:1-17:29
Location: in C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf: 1:0-1:28
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(1): object Zone “director-global” {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(2): global = true
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(3): }
[2022-10-06 11:13:11 +0200] critical/cli: Config validation failed. Re-run with ‘icinga2 daemon -C’ after fixing the config.

Infact, the entry director-global on my linux icinga server is on:
/var/lib/icinga2/api/packages/director/3c230beb-dfb0-497f-b33d-433a86646b19/zones.d/director-global/zones.conf

object Zone “director-global” {
global = true
}

and no more on:
/etc/icinga2/zones.conf
where the
object Zone “director-global” {
global = true
}
because it is commented.

So, I suppose that I have to remove, on my windows host, where the “Icinga for Windows” is installed, the entry:
object Zone “director-global” {
global = true
}
from C:\ProgramData\icinga2\etc\icinga2\zones.conf and restart the “Icinga 2” service.
So, now I have no trouble on C:\ProgramData\icinga2\var\lib\icinga2\api\zones-stage-startup.log

But the message from icinga check still gives:
Check command ‘Invoke-IcingaCheckCPU’ does not exist

How could I solve this?
Thanks a lot
Mario

Give as much information as you can, e.g.
icinga2 - The Icinga 2 network monitoring daemon (version: r2.13.1-1)
Icinga Web 2 Version
2.9.3
Git commit
c757a17530c326c7d6daebd6171486cb8167a8a1
PHP Version
7.2.24-0ubuntu0.18.04.10
Git commit date
2021-08-10
businessprocess 2.3.1
director 1.8.1
fileshipper 1.1.0
incubator 0.8.1
monitoring 2.9.3

I see C:\ProgramData\icinga2\var\lib\icinga2\api\zones-stage\director-global\director\commands.conf

It contains the command

object CheckCommand "Invoke-IcingaCheckCPU" {
    import "PowerShell Base"

    arguments += {
        "-C" = {
            order = 0
            value = "try { Use-Icinga -Minimal; } catch { Write-Output 'The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details'; Write-Output 'Error:' $$($$_.Exception.Message)Components:`r`n$$( Get-Module -ListAvailable 'icinga-powershell-*' )`r`n'Module-Path:'`r`n$$($$Env:PSModulePath); exit 3; }; Exit-IcingaExecutePlugin -Command 'Invoke-IcingaCheckCPU' "
        }
        "-Core" = {
            order = 4
            value = "$IcingaCheckCPU_String_Core$"
        }
        "-Critical" = {
            order = 3
            value = "$IcingaCheckCPU_Object_Critical$"
        }
        "-NoPerfData" = {
            order = 99
            set_if = "$IcingaCheckCPU_Switchparameter_NoPerfData$"
        }
        "-ThresholdInterval" = {
            order = 100
            value = "$IcingaCheckCPU_String_ThresholdInterval$"
        }
        "-Verbosity" = {
            order = 5
            value = "$IcingaCheckCPU_Int32_Verbosity$"
        }
        "-Warning" = {
            order = 2
            value = "$IcingaCheckCPU_Object_Warning$"
        }
    }
    vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
}

object CheckCommand "PowerShell Base" {
    import "plugin-check-command"
    command = [
        "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    ]
    timeout = 3m
    arguments += {
        "-ExecutionPolicy" = {
            order = -1
            value = "$IcingaPowerShellBase_String_ExecutionPolicy$"
        }
        "-NoLogo" = {
            order = -2
            set_if = "1"
        }

So, I don’t understand if the message: Check command Invoke-IcingaCheckCPU’ does not exist
is from icinga server or windows host.

How could I investigate on this?

Thanks

I copy/paste the command:

object CheckCommand "Invoke-IcingaCheckCPU" {
    import "plugin-check-command"
    command = [
        "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    ]
    timeout = 3m
    arguments += {
        "-C" = {
            order = 0
            value = "Use-Icinga; 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_Int32_Verbosity = 0
    vars.IcingaCheckCPU_Object_Critical = "$$null"
    vars.IcingaCheckCPU_Object_Warning = "$$null"
    vars.IcingaCheckCPU_String_Core = "*"
    vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
}

into the file:
C:\Program Files\ICINGA2\share\icinga2\include\command-plugins-windows.conf

and it works.
So, I would like to understand if have I to copy it manually, and why hasn’t it been imported automatically?

Anyone could help me?
Thanks a lot
Mario

please post the zones.conf from your windows machine

This is C:\ProgramData\icinga2\etc\icinga2\zones.conf

object Endpoint "myicingaservermaster.mydomain.net" {
}

object Endpoint "myicingaservermaster.mydomain.net" {
    host = "172.16.1.60";
}

object Zone "myicingaservermaster.mydomain.net" {
    endpoints = [ "myicingaservermaster.mydomain.net" ];
}

object Zone "windowshost.mydomain.net" {
    parent = "myicingaservermaster.mydomain.net";
    endpoints = [ "windowshost.mydomain.net" ];
}


object Zone "global-templates" {
    global = true;
}


i think, that your check was deployed in director-global, but your host does not know that it should fetch the global-zone director global because the entry for director-global is missing

In the first step, I created json file to import into Director by Configuration Basket-> Upload, etc.

Later, I decided to put the Invoke-* command into a file mycommandwindows.conf on my Icinga server (master, the only one myicingaservermaster.mydomain.net) located in /etc/icinga2/conf.d
So, I executed Director->Kickstart Wizard so the commands became known by Director, as External Commands.

But my windows host, didn’t know those commands, until I copied the
mycommandwindows.conf into C:\Program Files\ICINGA2\share\icinga2\include
and I modified the file plugins adding a reference to mycommandwindows.conf

This is the content of C:\Program Files\ICINGA2\share\icinga2\include\plugins

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

/**
 * This is the Icinga Templare Library, a collection of general purpose Icinga
 * configuration templates. This part includes the plugin commands.
 */

include "command-plugins.conf"
include "mycommandwindows.conf"

So, as you wrote, I would like to find the windows commands already known, but I was not able to obtain it, until I executed the steps above.

If you have some suggestions for me, I appreciate it

thanks a lot
Mario

Is there any method to include my custom windows command?

I tried to put into /usr/share/icinga2/include/plugins-contrib.d/mycommandwindows.conf
but when I install “Icinga for Windows” I don’t find it into:
C:\Program Files\ICINGA2\share\icinga2\include\plugins-contrib.d
so I have to copy mycommandwindows.conf manually into the above windows folder.

So, is there any way to obtain it automatically?

Thanks a lot
Mario

i think, that your check was deployed in director-global, but your host does not know that it should fetch the global-zone director global because the entry for director-global is missing

I reinstalled Icinga for windows, without adding the mycommandwindows.conf manually.

I read the zones-stage-startup.log

[2022-10-20 09:09:10 +0200] information/cli: Icinga application loader (version: v2.13.5)
[2022-10-20 09:09:10 +0200] information/cli: Loading configuration file(s).
[2022-10-20 09:09:10 +0200] critical/config: Error: Object 'director-global' of type 'Zone' re-defined: in C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf: 1:0-1:28; previous definition: in C:/ProgramData/icinga2/etc/icinga2/zones.conf: 16:1-16:29
Location: in C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf: 1:0-1:28
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(1): object Zone "director-global" {
                                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(2):     global = true
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(3): }
[2022-10-20 09:09:10 +0200] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

And this is the content of C:\ProgramData\icinga2\etc\icinga2\zones.conf

object Endpoint "windowshostname.mydomain.net" {
}

object Endpoint "icingaserverhostname.mydomain.net" {
}

object Zone "icingaserverhostname.mydomain.net" {
    endpoints = [ "icingaserverhostname.mydomain.net" ];
}

object Zone "windowshostname.mydomain.ne" {
    parent = "icingaserverhostname.mydomain.net";
    endpoints = [ "windowshostname.mydomain.net" ];
}

object Zone "director-global" {
    global = true;
}

object Zone "global-templates" {
    global = true;
}

So, I am a little bit confused about how to solve my issue…

backup and delete the api directory, if everything works it should be resynced by icinga2

I tried, but I see the same log and the commands aren’t recognized by windows host.

[2022-10-20 12:13:30 +0200] information/cli: Icinga application loader (version: v2.13.5)
[2022-10-20 12:13:30 +0200] information/cli: Loading configuration file(s).
[2022-10-20 12:13:30 +0200] critical/config: Error: Object 'director-global' of type 'Zone' re-defined: in C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf: 1:0-1:28; previous definition: in C:/ProgramData/icinga2/etc/icinga2/zones.conf: 16:1-16:29
Location: in C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf: 1:0-1:28
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(1): object Zone "director-global" {
                                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(2):     global = true
C:/ProgramData/icinga2/var/lib/icinga2/api/zones-stage/director-global/director/zones.conf(3): }
[2022-10-20 12:13:30 +0200] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

Hello,
anyone knows some suggestions about my issue?

Thanks a lot

Mario

Hello, I’ve had the same issue.
In my case I’m using a CustomPluginDir.

I had to put the following in my constants.conf for it to work:
const CustomPluginDir = "C:\\Program Files\\ICINGA2\\custom"

Maybe you should start an priviledged admin powershell, and inspect the log with:


Read-IcingaAgentLogFile;

Whats is happening when you start an privilegded admin powershell, and put in this command:

powershell -C { Use-Icinga; Invoke-IcingaCheckCPU -Warning 75 -Critical 85 -Verbosity 2; }

regards from sdohn