Icinga2-Powershell framework with icinga2 - Issues

I have been following this https://github.com/Icinga/icinga-powershell-framework/issues/25

& i am trying to use Invoke-IcingaCheckCPU for cpu monitoring… i would like to understand whats wrong i did…

Here the command that entered on commands.conf file

object CheckCommand “check-cpu” {

    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"

        }

        "-Critical" = {

            order = 2

            value = "$PowerShell_Critical$"

        }

        "-NoPerfData" = {

            order = 6

            set_if = "$PowerShell_NoPerfData$"

        }

        "-Verbose" = {

            order = 4

            value = "$PowerShell_Verbose$"

        }

        "-Warning" = {

            order = 1

            value = "$PowerShell_Warning$"

        }

    }

    vars.PowerShell_Critical = "$$null"

    vars.PowerShell_NoPerfData = "0"

    vars.PowerShell_Verbose = "0"

    vars.PowerShell_Warning = "$$null"

}

Here, the service block

apply Service "checkcpu" {

    import "generic-service"

    check_command = "check-cpu"

    vars.PowerShell_Warning = "80"

    vars.PowerShell_Critical = "95"

    max_check_attempts = 1

    check_interval = 10s

    retry_interval = 4s

    enable_notifications = false

    command_endpoint = host.vars.client_endpoint

    assign where host.endpoint && host.vars.powershell_framework == true && (host.vars.os == "Windows" || host.vars.os == "AWS-Windows")

}

Attached screenshot of the commands that ran on the target host. This is not working at all…

I am not able to the metric on icinga2 UI & when i tried to validate the master icinga2 configs i see the below error…
[2020-03-19 20:01:43 -0600] warning/ApplyRule: Apply rule 'checkcpu' (in /etc/icinga2/zones.d/master/global-templates/windows-services.conf: 72:1-72:24) for type 'Service' does not match an ywhere!

Sample host file… Can you please advise me whats wrong i did?

object Zone "###########################" {
     endpoints = [ "########################" ]
     parent = "master"
}

// Host Objects
object Host "#####################" {
    check_command = "hostalive"
    address = "###################"
    vars.os="Windows"
    vars.app_type="db"
    vars.client_endpoint = name //follows the convention that host name == endpoint name
#    vars.nscp_api_password = "577c8ff8ad24864c"
// Custom Optional check - START
    vars.local_disks["/app Filesystem"] = {
       disk_partitions = "/app"
  }

    vars.local_http_vhosts["http"] = {
       http_uri = "/"
  }
  vars.nscp_boot = false
    vars.notification["mail"] = {
        groups = [ "icingausers" ]
        users = [ "icingaadmin" ]
}
    vars.notification["sms"] = {
        users = [ "icingaadmin" ]
}

    vars.local_tcp_port["tcp"] ={
       tcp_port = "23"
       service_name = "Telnet Check"
       port_number = "Port 23"
  }
// Custom Optional Check - END
}

Hello and thank you for trying the Icinga for Windows monitoring!

Is the agent able to connect to the systems? You can use the Log-Command to tail the current log and check if the Agent is writing any errors:

Use-Icinga;
Read-IcingaAgentLogFile;

In addition, you could lookup if the Check-Command has been deployed to your Windows Host:

Use-Icinga;
Find-IcingaAgentObjects -Find '*check-cpu*';

In addition, the background daemon will not work because the cache directory is not writeable. As mentioned inside the test output. please execute

Use-Icinga;
Set-IcingaAcl -Directory 'C:\Progam Files\WindowsPowerShell\Modules\icinga-powershell-framework\v1.0.0\cache'

Afterwards

Restart-IcingaService icingapowershell;

Please check then if the service is running properly:

Get-Service icingapowershell;

I hope this helps ! Feel free to ask additional questions here.

many thanks for your response… Here the output i see as shown below… I am really new to powershell…

Only thing that i have been trying this for cpu monitoring… with NSclient++ & icinga2 plugins cpu monitoring really weird…

Can you please help on this?

Have you run the Setup-Wizard for the Framework?
It looks to me it is only partial intalled.

Use-Icinga;
Start-IcingaAgentInstallWizard;

The wizard will guide you through the entire installation and configuration. Afterwards everything should be working properly.

Im just realising that the documentation is lacking this information basicly. I will improve this shortly!

What the Install Wizard will do is ask you plenty of different questions on how your system should be configured (Icinga 2 related) and where to install Plugins / the Service from.

Once done, your system should work properly.

Sorry for that!

It has icinga2 already installed… I can see all the metrics on icinga2 UI…

Start-IcingaAgentInstallWizard; is something different from normal install? it should not be right…

i can see all the metrics… i have already installed the powershell module for Icinga2 & NSclient++ installation…

I can see all the metrics as well… I am only worrying about cpu which i have done throuh powershell framework.

**

**

I’m wondering where the problem is then. Is the check not deployed to Icinga 2?
In general you should see the checkcpu service if it is assigned to the host. Does it show up there and if yes, which results are you receiving?

The Framework will simply provide a source and foundation for Icinga Plugins. They are all executed through the Icinga 2 Agent on the system or - if you want to any reason - by the NSClient++.

The background daemon will simply allow you to register checks and frequently execute them to provide metrics over time (as NSClient++ is doing). As of yet, the Framework is not capable to send data back to Icinga 2 directly.

you still require either Icinga 2 or the NSClient++ to actually execute the check.

So basicly im wondering, why your check-cpu Check-Command is not transfered to the Agent. Is the service not listed at all on this host?

actually check-cpu is not showing on Icinga2 UI :neutral_face: Yeah service is not listed at all on the host in ICinga2 UI… Do you think i missed something in configurations?

HI,

if it’s not a copy and paste error on your first post then yes. I only found that you are using in your service the assign rule:

assign where host.endpoint && host.vars.powershell_framework == true && (host.vars.os == "Windows" || host.vars.os == "AWS-Windows")

but you use host.endpoint which does not exists? maybe you meant host.vars.client_endpoint and host.vars.powershell_framework is also not set on the host - so the service doesn’t get applied to the host:

Greetz

This is cleared… I had to add commands.conf to global templates folder… previously it was under conf.d.

I am able to see the metric on icinga2 UI with an error…

On check execution -> its clearly shows its executing on remote box… when manually login into remote machine… ran the commands, I am able to see the cpu information

Here, my command

object CheckCommand "check-cpu" {

    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"

        }

        "-Critical" = {

            order = 2

            value = "$PowerShell_Critical$"

        }

        "-NoPerfData" = {

            order = 6

            set_if = "$PowerShell_NoPerfData$"

        }

        "-Verbose" = {

            order = 4

            value = "$PowerShell_Verbose$"

        }

        "-Warning" = {

            order = 1

            value = "$PowerShell_Warning$"

        }

    }

    vars.PowerShell_Critical = "$$null"

    vars.PowerShell_NoPerfData = "0"

    vars.PowerShell_Verbose = "0"

    vars.PowerShell_Warning = "$$null"

}

&
service block

apply Service "checkcpu" {

    import "generic-service"

    check_command = "check-cpu"

    vars.PowerShell_Warning = "80"

    vars.PowerShell_Critical = "95"

    max_check_attempts = 1

    check_interval = 10s

    retry_interval = 4s

    enable_notifications = false

    command_endpoint = host.vars.client_endpoint

    assign where host.vars.client_endpoint && host.vars.powershell_framework == true && (host.vars.os == "Windows" || host.vars.os == "AWS-Windows")

}

& first part of host file

bject Host “**********************” {

check_command = "hostalive"

address = "*************"

vars.os="Windows"

vars.powershell_framework = true

vars.app_type="db"

# vars.SSMAgent = "AmazonSSMAgent"

# vars.win_services["ClusterAmazonSSMAgent"] = { service_win_service="AmazonSSMAgent" }

vars.client_endpoint = name //follows the convention that host name == endpoint name

Apologies. for asking multiple questions… Any advise would be much appreciated

Can you please advise on this?

I am able to see the check-cpu check as shown below… Still it think that command doesn’t exist.

Hello Mani ,

Did you find a fix for this ?

What is the check source of this service object? Is it the Windows host?