From dfb057a07930d6f71e1eae1b8127f03da31f1052 Mon Sep 17 00:00:00 2001 From: audiocoach Date: Wed, 3 Apr 2024 12:54:43 +0200 Subject: [PATCH] fixed pagefile percentage thresholds when "manage pagefile for all disks automatically" is disabled but "automatically managed" is enabled for specifc pagefiles --- .../Get-IcingaMemoryPerformanceCounter.psm1 | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/provider/memory/Get-IcingaMemoryPerformanceCounter.psm1 b/provider/memory/Get-IcingaMemoryPerformanceCounter.psm1 index 2bbe1f58..7db242b6 100644 --- a/provider/memory/Get-IcingaMemoryPerformanceCounter.psm1 +++ b/provider/memory/Get-IcingaMemoryPerformanceCounter.psm1 @@ -57,18 +57,20 @@ function Global:Get-IcingaMemoryPerformanceCounter() continue; } - $MemoryData.PageFile.Add( - $entry.Name, - @{ - 'InitialSize' = $entry.InitialSize * 1024 * 1024; - 'Managed' = $TRUE; - 'Name' = $entry.Name; - 'TotalSize' = $entry.MaximumSize * 1024 * 1024; - } - ); + if ($entry.MaximumSize -ne 0) { + $MemoryData.PageFile.Add( + $entry.Name, + @{ + 'InitialSize' = $entry.InitialSize * 1024 * 1024; + 'Managed' = $TRUE; + 'Name' = $entry.Name; + 'TotalSize' = $entry.MaximumSize * 1024 * 1024; + } + ); - $MemoryData['PageFile Total Bytes'] += $entry.MaximumSize * 1024 * 1024; - $MemoryData['PageFile Used Bytes'] += $entry.InitialSize * 1024 * 1024; + $MemoryData['PageFile Total Bytes'] += $entry.MaximumSize * 1024 * 1024; + $MemoryData['PageFile Used Bytes'] += $entry.InitialSize * 1024 * 1024; + } } }