From 26de830d776c7326080753c0a0cd0583a9e7bc3c Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Fri, 20 Feb 2026 16:51:39 +0100 Subject: [PATCH] Fixes Invoke-IcingaCheckPartitionSpace to report unknown if no usage data was found --- doc/31-Changelog.md | 8 ++++++++ plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 | 6 ++++++ provider/disks/Get-IcingaPartitionSpace.psm1 | 8 +++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 11871a4e..50b5f025 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -7,6 +7,14 @@ documentation before upgrading to a new release. Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-plugins/milestones?state=closed). +## 1.14.1 (tbd) + +[Issue and PRs](https://github.com/Icinga/icinga-powershell-plugins/milestone/23) + +### 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 + ## 1.14.0 (2026-02-11) [Issue and PRs](https://github.com/Icinga/icinga-powershell-plugins/milestone/22) 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 8a33b0bf..bff2601d 100644 --- a/provider/disks/Get-IcingaPartitionSpace.psm1 +++ b/provider/disks/Get-IcingaPartitionSpace.psm1 @@ -36,12 +36,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);