Skip to content

Icinga Agent integration as Framework Modules

This PowerShell modules provides a wide range of Check-Plugins for Icinga 2 to fetch information from a Windows system. Once the module is installed, the Plugins are ready to use.

Requirements

To properly work we recommend using the Icinga 2 Agent.

Usage of the Check-Commands

Each call from the Icinga 2 Agent requires a short initialisation of the module. This can either be done by using the Import-Module Cmdlet in case the module is not autoloaded, or by calling

Use-Icinga;

before each function call. An example on the PowerShell would be this:

Use-Icinga; Invoke-IcingaCheckCPU;

This will initialise the module and execute the Check-Command afterwards.

Check-Command definition for Icinga

A example Check-Command for Icinga could look like this:

object CheckCommand "PowerShell Base" {
    import "plugin-check-command"
    command = [
        "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    ]
    timeout = 3m
}

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

    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_String_Core = "*"
    vars.IcingaCheckCPU_Object_Critical = "$$null"
    vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
    vars.IcingaCheckCPU_Int32_Verbosity = 0
    vars.IcingaCheckCPU_Object_Warning = "$$null"
}

This will call the PowerShell, execute the provided initialisation function Use-Icinga and afterwards execute the Check-Plugin with the provided arguments.

Unlike other PowerShell integrations, it will automatically exit with the proper exit code - no special handling is required here.