Skip to content

Commit 2979742

Browse files
committed
Fixes Invoke-IcingaCheckPartitionSpace to report unknown if no usage data was found
1 parent 890eb59 commit 2979742

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ function Invoke-IcingaCheckPartitionSpace()
181181
} else {
182182
$IcingaCheck.SetOk('No disk size available', $TRUE) | Out-Null;
183183
}
184+
} elseif ([string]::IsNullOrEmpty($partition.FreeSpace) -or [string]::IsNullOrEmpty($partition.UsedSpace)) {
185+
if ($SkipUnknown -eq $FALSE) {
186+
$IcingaCheck.SetUnknown('No disk usage size available', $TRUE) | Out-Null;
187+
} else {
188+
$IcingaCheck.SetOk('No disk usage available', $TRUE) | Out-Null;
189+
}
184190
} else {
185191
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
186192
}

provider/disks/Get-IcingaPartitionSpace.psm1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ function Get-IcingaPartitionSpace()
3636
break;
3737
}
3838

39+
$UsedSpace = $null;
40+
41+
if ($null -ne $disk.FreeSpace) {
42+
$UsedSpace = $DiskSize - [decimal]$disk.FreeSpace;
43+
}
44+
3945
$DiskData.Add(
4046
$disk.Name,
4147
@{
4248
'Size' = $DiskSize;
4349
'FreeSpace' = $disk.FreeSpace;
44-
'UsedSpace' = ($DiskSize - $disk.FreeSpace);
50+
'UsedSpace' = $UsedSpace;
4551
'DriveLetter' = $disk.DriveLetter;
4652
'DriveName' = $disk.Name;
4753
'HasLetter' = -not [string]::IsNullOrEmpty($disk.DriveLetter);

0 commit comments

Comments
 (0)