Skip to content

Commit 9e07cfc

Browse files
committed
Fixes pagefile provider returning values in MB instead of Bytes
1 parent bb77d0e commit 9e07cfc

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1212
### Bugfixes
1313

1414
* [#342](https://github.com/Icinga/icinga-powershell-plugins/issues/342) Fixes an issue for disk health plugin, which can fail in some cases due to an invalid conversion from the MSFT output from int to string
15+
* [#346](https://github.com/Icinga/icinga-powershell-plugins/pull/346) Fixes the pagefile provider at `Get-IcingaMemoryPerformanceCounter` which returned the pagefile size in MB instead of Bytes
1516

1617
## 1.10.1 (2022-12-20)
1718

provider/memory/Get-IcingaMemoryPerformanceCounter.psm1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ function Global:Get-IcingaMemoryPerformanceCounter()
6060
$MemoryData.PageFile.Add(
6161
$entry.Name,
6262
@{
63-
'InitialSize' = $entry.InitialSize;
63+
'InitialSize' = $entry.InitialSize * 1024 * 1024;
6464
'Managed' = $TRUE;
6565
'Name' = $entry.Name;
66-
'TotalSize' = $entry.MaximumSize;
66+
'TotalSize' = $entry.MaximumSize * 1024 * 1024;
6767
}
6868
);
6969

70-
$MemoryData['PageFile Total Bytes'] += $entry.MaximumSize;
71-
$MemoryData['PageFile Used Bytes'] += $entry.InitialSize;
70+
$MemoryData['PageFile Total Bytes'] += $entry.MaximumSize * 1024 * 1024;
71+
$MemoryData['PageFile Used Bytes'] += $entry.InitialSize * 1024 * 1024;
7272
}
7373
}
7474

@@ -78,13 +78,13 @@ function Global:Get-IcingaMemoryPerformanceCounter()
7878
foreach ($entry in $PageFileUsage) {
7979
if ($MemoryData.PageFile.ContainsKey($entry.Name)) {
8080
$MemoryData.PageFile[$entry.Name].Add(
81-
'Allocated', $entry.AllocatedBaseSize
81+
'Allocated', $entry.AllocatedBaseSize * 1024 * 1024
8282
);
8383
$MemoryData.PageFile[$entry.Name].Add(
84-
'Usage', $entry.CurrentUsage
84+
'Usage', $entry.CurrentUsage * 1024 * 1024
8585
);
8686
$MemoryData.PageFile[$entry.Name].Add(
87-
'PeakUsage', $entry.PeakUsage
87+
'PeakUsage', $entry.PeakUsage * 1024 * 1024
8888
);
8989
$MemoryData.PageFile[$entry.Name].Add(
9090
'TempPageFile', $entry.TempPageFile
@@ -97,18 +97,18 @@ function Global:Get-IcingaMemoryPerformanceCounter()
9797
@{
9898
'InitialSize' = 0;
9999
'MaximumSize' = 0;
100-
'TotalSize' = $entry.AllocatedBaseSize;
101-
'Allocated' = $entry.AllocatedBaseSize;
102-
'Usage' = $entry.CurrentUsage;
103-
'PeakUsage' = $entry.PeakUsage;
100+
'TotalSize' = $entry.AllocatedBaseSize * 1024 * 1024;
101+
'Allocated' = $entry.AllocatedBaseSize * 1024 * 1024;
102+
'Usage' = $entry.CurrentUsage * 1024 * 1024;
103+
'PeakUsage' = $entry.PeakUsage * 1024 * 1024;
104104
'TempPageFile' = $entry.TempPageFile;
105105
'Managed' = $FALSE;
106106
'Name' = $entry.Name;
107107
}
108108
);
109109

110-
$MemoryData['PageFile Total Bytes'] += $entry.AllocatedBaseSize;
111-
$MemoryData['PageFile Used Bytes'] += $entry.CurrentUsage;
110+
$MemoryData['PageFile Total Bytes'] += $entry.AllocatedBaseSize * 1024 * 1024;
111+
$MemoryData['PageFile Used Bytes'] += $entry.CurrentUsage * 1024 * 1024;
112112
}
113113

114114
foreach ($entry in $PerfCounters['\Paging File(*)\% usage'].Keys) {

0 commit comments

Comments
 (0)