Skip to content

Feature Request: Add Health Status to Invoke-IcingaCheckDiskHealth #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
audiocoach opened this issue Feb 25, 2024 · 3 comments · Fixed by #444
Closed

Feature Request: Add Health Status to Invoke-IcingaCheckDiskHealth #389

audiocoach opened this issue Feb 25, 2024 · 3 comments · Fixed by #444
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@audiocoach
Copy link

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.

@LordHepipud LordHepipud self-assigned this Mar 2, 2024
@LordHepipud LordHepipud added the enhancement New feature or request label Mar 2, 2024
@audiocoach
Copy link
Author

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);

@Aleksey-Maksimov
Copy link

+1

@LordHepipud
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants