From 0dd9e18e88cac93a0b8de36be87ae6d7efda0f9a Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Mon, 30 Mar 2026 13:22:31 +0200 Subject: [PATCH] Fixes Invoke-IcingaCheckPartitionSpace to report unknown if no usage data was found --- doc/31-Changelog.md | 1 + plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 | 6 ++++++ provider/disks/Get-IcingaPartitionSpace.psm1 | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index ad92267c..9233212b 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -13,6 +13,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic ### Bugfixes +* [#471](https://github.com/Icinga/icinga-powershell-plugins/pull/471) Fixes `Invoke-IcingaCheckPartitionSpace` to report `UNKNOWN` if no usage data was used, which was previously handled by "No disk size available". As we now properly receive disk size data but still no usage data in these cases, we receive false positives * [#472](https://github.com/Icinga/icinga-powershell-plugins/pull/472) Fixes the partition size provider to no longer map the volume to partition by using the drive letter, but the device id instead, to ensure real partition size is applied for every use case ## 1.14.0 (2026-02-11) diff --git a/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 b/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 index 0c212c57..94066445 100644 --- a/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 +++ b/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 @@ -181,6 +181,12 @@ function Invoke-IcingaCheckPartitionSpace() } else { $IcingaCheck.SetOk('No disk size available', $TRUE) | Out-Null; } + } elseif ([string]::IsNullOrEmpty($partition.FreeSpace) -or [string]::IsNullOrEmpty($partition.UsedSpace)) { + if ($SkipUnknown -eq $FALSE) { + $IcingaCheck.SetUnknown('No disk usage size available', $TRUE) | Out-Null; + } else { + $IcingaCheck.SetOk('No disk usage available', $TRUE) | Out-Null; + } } else { $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; } diff --git a/provider/disks/Get-IcingaPartitionSpace.psm1 b/provider/disks/Get-IcingaPartitionSpace.psm1 index 1c24d90b..803c8225 100644 --- a/provider/disks/Get-IcingaPartitionSpace.psm1 +++ b/provider/disks/Get-IcingaPartitionSpace.psm1 @@ -32,12 +32,18 @@ function Get-IcingaPartitionSpace() break; } + $UsedSpace = $null; + + if ($null -ne $disk.FreeSpace) { + $UsedSpace = $DiskSize - [decimal]$disk.FreeSpace; + } + $DiskData.Add( $disk.Name, @{ 'Size' = $DiskSize; 'FreeSpace' = $disk.FreeSpace; - 'UsedSpace' = ($DiskSize - $disk.FreeSpace); + 'UsedSpace' = $UsedSpace; 'DriveLetter' = $disk.DriveLetter; 'DriveName' = $disk.Name; 'HasLetter' = -not [string]::IsNullOrEmpty($disk.DriveLetter);