Feature Request: Add Health Status to Invoke-IcingaCheckDiskHealth
audiocoach opened this issue · comments
Is there a specific reason why the health status is not part of the Invoke-IcingaCheckDiskHealth? If not it would be great if you can add it in a future update. According to https://learn.microsoft.com/en-us/powershell/module/storage/get-physicaldisk?view=windowsserver2022-ps there are 4 possible health states (Healthy, Unhealthy, Unknown, Warning). According to https://learn.microsoft.com/de-de/windows-hardware/drivers/storage/msft-disk there are three possible states (Healthy, Unhealthy, Warning).
In Invoke-IcingaCheckDiskHealth this attribute is checked so I think it should be easy to add it to the Invoke-IcingaCheckDiskHealth.
Here is a possible solution for that:
add the following to the Icinga_ProviderEnums at C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-plugins\provider\enums
# https://docs.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/msft-physicaldisk
[hashtable]$DiskHealthStatus = @{
0 = 'Healthy';
1 = 'Warning';
2 = 'Unhealthy';
5 = 'Unknown';
};
and within the same file add the following entry to the existing [hashtable]$ProviderEnums
DiskHealthStatus = $DiskHealthStatus;
In the Get-IcingaPhysicalDiskInfo at C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-plugins\provider\disks replace Line 226
$DiskInfo.Add('HealthStatus', $disk.HealthStatus);
with the following
$DiskInfo.Add(
'HealthStatus',
@{
'Value' = $disk.HealthStatus;
'Name' = (Get-IcingaProviderEnumData -Enum $ProviderEnums -Key 'DiskHealthStatus' -Index $disk.HealthStatus);
}
);
and finally add the following to the IInvoke-IcingaCheckDiskHealth at C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-plugins\plugins below Line 222
$DiskHealthStatusCheck = New-IcingaCheck `
-Name ([string]::Format('{0} Health Status', $Partition)) `
-Value ([string]$DiskObjects.Data.HealthStatus.Name) `
-NoPerfData;
$DiskHealthStatusCheck.WarnIfMatch('Warning') | Out-Null;
$DiskHealthStatusCheck.CritIfMatch('Unhealthy') | Out-Null;
$DiskHealthStatusCheck.CritIfMatch('Unknown') | Out-Null;
$PartCheckPackage.AddCheck($DiskHealthStatusCheck);