-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"DataList":{"IcingaCheckMPIO Verbosity":{"list_name":"IcingaCheckMPIO Verbosity","originalId":"2","entries":[{"allowed_roles":null,"entry_value":"0","entry_name":"0","format":"string"},{"allowed_roles":null,"entry_value":"1","entry_name":"1","format":"string"},{"allowed_roles":null,"entry_value":"2","entry_name":"2","format":"string"},{"allowed_roles":null,"entry_value":"3","entry_name":"3","format":"string"}],"owner":"yhabteab"}},"Command":{"Invoke-IcingaCheckMPIO":{"fields":[{"datafield_id":2,"is_required":"n","var_filter":null},{"datafield_id":3,"is_required":"n","var_filter":null},{"datafield_id":4,"is_required":"n","var_filter":null},{"datafield_id":5,"is_required":"n","var_filter":null},{"datafield_id":6,"is_required":"n","var_filter":null}],"object_name":"Invoke-IcingaCheckMPIO","arguments":{"-C":{"value":"try { Use-Icinga -Minimal; } catch { Write-Output \u0027The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details\u0027; exit 3; }; Exit-IcingaExecutePlugin -Command \u0027Invoke-IcingaCheckMPIO\u0027 ","order":"0"},"-Verbosity":{"value":"$IcingaCheckMPIO_Object_Verbosity$","order":"4"},"-NumberPathWarn":{"value":"$IcingaCheckMPIO_Object_NumberPathWarn$","order":"2"},"-NumberPathCrit":{"value":"$IcingaCheckMPIO_Object_NumberPathCrit$","order":"3"},"-ThresholdValue":{"value":"$IcingaCheckMPIO_String_ThresholdValue$","order":"100"},"-NoPerfData":{"set_if":"$IcingaCheckMPIO_Switchparameter_NoPerfData$","set_if_format":"string","order":"99"}},"imports":["PowerShell Base"],"object_type":"object","vars":{"IcingaCheckMPIO_Switchparameter_NoPerfData":false}},"PowerShell Base":{"methods_execute":"PluginCheck","object_name":"PowerShell Base","vars":{},"is_string":null,"command":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","zone":null,"disabled":false,"fields":[],"arguments":{},"imports":[],"object_type":"object","timeout":"180"}},"Datafield":{"2":{"settings":{"visibility":"visible"},"description":"Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring.","caption":"ThresholdValue","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"2","varname":"IcingaCheckMPIO_String_ThresholdValue","format":null},"5":{"settings":{"visibility":"visible"},"description":"Disables the performance data output of this plugin","caption":"NoPerfData","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeBoolean","originalId":"5","varname":"IcingaCheckMPIO_Switchparameter_NoPerfData","format":null},"4":{"settings":{"visibility":"visible"},"description":"Used to specify a Warning threshold.","caption":"NumberPathCrit","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"4","varname":"IcingaCheckMPIO_Object_NumberPathCrit","format":null},"3":{"settings":{"visibility":"visible"},"description":"Used to specify a Warning threshold.","caption":"NumberPathWarn","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeString","originalId":"3","varname":"IcingaCheckMPIO_Object_NumberPathWarn","format":null},"6":{"settings":{"datalist":"IcingaCheckMPIO Verbosity","behavior":"strict","data_type":"string"},"description":"Changes the behavior of the plugin output which check states are printed:\n0 (default): Only service checks/packages with state not OK will be printed\n1: Only services with not OK will be printed including OK checks of affected check packages including Package config\n2: Everything will be printed regardless of the check state\n3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])","caption":"Verbosity","datatype":"Icinga\\Module\\Director\\DataType\\DataTypeDatalist","originalId":"6","varname":"IcingaCheckMPIO_Object_Verbosity","format":null}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
object CheckCommand "Invoke-IcingaCheckMPIO" { | ||
import "PowerShell Base" | ||
|
||
arguments += { | ||
"-C" = { | ||
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'; exit 3; }; Exit-IcingaExecutePlugin -Command 'Invoke-IcingaCheckMPIO' " | ||
order = 0 | ||
} | ||
"-Verbosity" = { | ||
description = "Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK])" | ||
value = "$IcingaCheckMPIO_Object_Verbosity$" | ||
order = 4 | ||
} | ||
"-NumberPathWarn" = { | ||
description = "Used to specify a Warning threshold." | ||
value = "$IcingaCheckMPIO_Object_NumberPathWarn$" | ||
order = 2 | ||
} | ||
"-NumberPathCrit" = { | ||
description = "Used to specify a Warning threshold." | ||
value = "$IcingaCheckMPIO_Object_NumberPathCrit$" | ||
order = 3 | ||
} | ||
"-ThresholdValue" = { | ||
description = "Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described here: https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/ An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring." | ||
value = "$IcingaCheckMPIO_String_ThresholdValue$" | ||
order = 100 | ||
} | ||
"-NoPerfData" = { | ||
set_if = "$IcingaCheckMPIO_Switchparameter_NoPerfData$" | ||
order = 99 | ||
} | ||
} | ||
vars.IcingaCheckMPIO_Switchparameter_NoPerfData = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Invoke-IcingaCheckMPIO | ||
|
||
## Description | ||
|
||
Monitors the number of paths for each MPIO driver on your system. | ||
|
||
Monitors the number of paths for each MPIO driver on your system. | ||
|
||
## Permissions | ||
|
||
To execute this plugin you will require to grant the following user permissions. | ||
|
||
### WMI Permissions | ||
|
||
* Root\WMI | ||
|
||
## Arguments | ||
|
||
| Argument | Type | Required | Default | Description | | ||
| --- | --- | --- | --- | --- | | ||
| NumberPathWarn | Object | false | | Used to specify a Warning threshold. | | ||
| NumberPathCrit | Object | false | | Used to specify a Warning threshold. | | ||
| NoPerfData | SwitchParameter | false | False | Disables the performance data output of this plugin | | ||
| Verbosity | Object | false | 0 | Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) | | ||
| ThresholdInterval | Object | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. | |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<# | ||
.SYNOPSIS | ||
Monitors the number of paths for each MPIO driver on your system. | ||
.DESCRIPTION | ||
Monitors the number of paths for each MPIO driver on your system. | ||
.PARAMETER NumberPathWarn | ||
Used to specify a Warning threshold. | ||
.PARAMETER NumberPathCrit | ||
Used to specify a Warning threshold. | ||
.PARAMETER NoPerfData | ||
Disables the performance data output of this plugin | ||
.PARAMETER Verbosity | ||
Changes the behavior of the plugin output which check states are printed: | ||
0 (default): Only service checks/packages with state not OK will be printed | ||
1: Only services with not OK will be printed including OK checks of affected check packages including Package config | ||
2: Everything will be printed regardless of the check state | ||
3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) | ||
.ROLE | ||
### WMI Permissions | ||
* Root\WMI | ||
.EXAMPLE | ||
PS> icinga { Invoke-IcingaCheckMPIO -Verbosity 3 } | ||
[OK] Check package "Multipath-IO Package" (Match All) | ||
\_ [OK] Check package "HostName Package" (Match All) | ||
\_ [OK] HostName Active: True | ||
\_ [OK] Check package "HostName Drivers Package" (Match All) | ||
\_ [OK] MPIO DISK0 Number Paths: 8c | ||
\_ [OK] MPIO DISK1 Number Paths: 8c | ||
\_ [OK] MPIO DISK2 Number Paths: 8c | ||
\_ [OK] MPIO DISK3 Number Paths: 8c | ||
\_ [OK] MPIO DISK4 Number Paths: 8c | ||
\_ [OK] HostName NumberDrives: 5c | ||
| 'hostname_numberdrives'=5c;; 'mpio_disk0_number_paths'=8c;; 'mpio_disk3_number_paths'=8c;; 'mpio_disk4_number_paths'=8c;; 'mpio_disk2_number_paths'=8c;; 'mpio_disk1_number_paths'=8c;; | ||
0 | ||
#> | ||
|
||
function Invoke-IcingaCheckMPIO() | ||
{ | ||
param ( | ||
$NumberPathWarn = $null, | ||
$NumberPathCrit = $null, | ||
[switch]$NoPerfData, | ||
[ValidateSet(0, 1, 2, 3)] | ||
$Verbosity = 0 | ||
); | ||
|
||
$CheckPackage = New-IcingaCheckPackage -Name 'Multipath-IO Package' -OperatorAnd -Verbose $Verbosity -AddSummaryHeader; | ||
$MpioDatas = Get-IcingaMPIOData; | ||
|
||
if ($MpioDatas.ContainsKey('Exception') -eq $FALSE) { | ||
foreach ($name in $MpioDatas.Keys) { | ||
$instance = $MpioDatas[$name]; | ||
|
||
$MpioCheckPackage = New-IcingaCheckPackage -Name ([string]::Format('{0} Package', $name)) ` -OperatorAnd -Verbose $Verbosity; | ||
$DriverPackage = New-IcingaCheckPackage -Name ([string]::Format('{0} Drivers Package', $name)) ` -OperatorAnd -Verbose $Verbosity; | ||
|
||
$MpioCheckPackage.AddCheck( | ||
( | ||
New-IcingaCheck ` | ||
-Name ([string]::Format('{0} Active', $name)) ` | ||
-Value $instance.Active ` | ||
-NoPerfData | ||
) | ||
); | ||
|
||
$MpioCheckPackage.AddCheck( | ||
( | ||
New-IcingaCheck ` | ||
-Name ([string]::Format('{0} NumberDrives', $name)) ` | ||
-Value $instance.NumberDrives ` | ||
-Unit 'c' | ||
) | ||
); | ||
|
||
foreach ($driverName in $instance.DriveInfo.Keys) { | ||
$driver = $instance.DriveInfo[$driverName]; | ||
$DriverPackage.AddCheck( | ||
( | ||
New-IcingaCheck ` | ||
-Name ([string]::Format('{0} Number Paths', $driverName)) ` | ||
-Value $driver.NumberPaths ` | ||
-Unit 'c' | ||
).WarnOutOfRange( | ||
$NumberPathWarn | ||
).CritOutOfRange( | ||
$NumberPathCrit | ||
) | ||
); | ||
} | ||
|
||
if ($DriverPackage.HasChecks()) { | ||
$MpioCheckPackage.AddCheck($DriverPackage); | ||
} | ||
|
||
$CheckPackage.AddCheck($MpioCheckPackage); | ||
} | ||
} else { | ||
$Check = New-IcingaCheck -Name 'MultiPath-IO Check Status' -NoPerfData; | ||
$Check.SetCritical($TestIcingaWindowsInfoEnums.TestIcingaWindowsInfoText[[int]$MpioDatas.Exception], $TRUE) | Out-Null; | ||
# Enforce the checks to critical in case we get an exception | ||
$CheckPackage.AddCheck($Check); | ||
} | ||
|
||
return (New-IcingaCheckResult -Check $CheckPackage -NoPerfData $NoPerfData -Compile); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets the basic information of the MPIO Device if the Multipath-IO windows feature is Installed on your system. | ||
.DESCRIPTION | ||
Gets the basic information of the MPIO Device if the Multipath-IO windows feature is Installed on your system. | ||
.OUTPUTS | ||
System.Collections.Hashtable | ||
#> | ||
|
||
function Get-IcingaMPIOData() | ||
{ | ||
if (-Not (Test-IcingaMPIOInstalled)) { | ||
Exit-IcingaThrowException -ExceptionType 'Custom' -CustomMessage 'MPIO not installed' -InputString 'The Multipath-IO feature is not installed on this system.' -Force; | ||
} | ||
|
||
# Check whether MPIO_DISK_INFO exists on the targeted system | ||
$TestClasses = Test-IcingaWindowsInformation -ClassName MPIO_DISK_INFO -NameSpace 'Root\WMI'; | ||
# Check for error Ids with Binary operators | ||
$BitWiseCheck = Test-IcingaBinaryOperator -Value $TestClasses -Compare @($TestIcingaWindowsInfoEnums.TestIcingaWindowsInfoExceptionType.Values) -Namespace $TestIcingaWindowsInfoEnums.TestIcingaWindowsInfo; | ||
# Get the lasth throw exception id | ||
$ExceptionId = Get-IcingaLastExceptionId; | ||
|
||
# We return a empty hashtable if for some reason no data from the WMI classes can be retrieved | ||
if ($BitWiseCheck) { | ||
if ($TestClasses -ne $TestIcingaWindowsInfoEnums.TestIcingaWindowsInfo.Ok) { | ||
return @{'Exception' = $TestClasses; }; | ||
} | ||
} | ||
|
||
# Throw an exception when the exception ID is not OK, NotSpecified and PermissionError | ||
if ($TestClasses -ne $TestIcingaWindowsInfoEnums.TestIcingaWindowsInfo.Ok) { | ||
Exit-IcingaThrowException ` | ||
-CustomMessage ($TestIcingaWindowsInfoEnums.TestIcingaWindowsInfoExceptionType[[int]$TestClasses]) ` | ||
-InputString ($TestIcingaWindowsInfoEnums.TestIcingaWindowsInfoText[[int]$TestClasses]) ` | ||
-ExceptionType Custom ` | ||
-Force; | ||
} | ||
|
||
$MpioDatas = Get-IcingaWindowsInformation -ClassName MPIO_DISK_INFO -Namespace 'Root\WMI'; | ||
$MpioDrivers = @{}; | ||
|
||
foreach ($instance in $MpioDatas) { | ||
if ($MpioDrivers.ContainsKey($instance.InstanceName)) { | ||
continue; | ||
} | ||
|
||
$MpioDrivers.Add( | ||
$instance.InstanceName, @{ | ||
'Active' = $instance.Active; | ||
'InstanceName' = $instance.InstanceName; | ||
'NumberDrives' = $instance.NumberDrives; | ||
'DriveInfo' = @{} | ||
} | ||
); | ||
|
||
foreach ($driver in $instance.DriveInfo) { | ||
if ($MpioDrivers[$instance.InstanceName].DriveInfo.ContainsKey($driver.Name)) { | ||
continue; | ||
} | ||
|
||
$MpioDrivers[$instance.InstanceName].DriveInfo.Add( | ||
$driver.Name, @{ | ||
'DsmName' = $driver.DsnName; | ||
'Name' = $driver.Name; | ||
'NumberPaths' = $driver.NumberPaths; | ||
'SerialNumber' = $driver.SerialNumber; | ||
'PSComputerName' = $driver.PSComputerName | ||
} | ||
); | ||
} | ||
} | ||
|
||
return $MpioDrivers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<# | ||
.SYNOPSIS | ||
Tests if the Multipath-IO windows feature is installed on the system without requiring administrative privileges | ||
.DESCRIPTION | ||
Tests if the Multipath-IO windows feature is installed on the system without requiring administrative privileges | ||
.OUTPUTS | ||
System.Boolean | ||
.LINK | ||
https://github.com/Icinga/icinga-powershell-PLUGINS | ||
#> | ||
|
||
function Test-IcingaMPIOInstalled() | ||
{ | ||
if (Test-IcingaFunction 'Get-WindowsFeature') { | ||
if ((Get-WindowsFeature -Name 'Multipath-IO').Installed) { | ||
return $TRUE; | ||
} | ||
} | ||
|
||
return $FALSE; | ||
} |