mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
18 lines
No EOL
917 B
PowerShell
18 lines
No EOL
917 B
PowerShell
function Get-IcingaMemoryPerformanceCounter()
|
|
{
|
|
$MemoryPercent = New-IcingaPerformanceCounterArray -Counter "\Memory\% committed bytes in use","\Memory\Available Bytes","\Paging File(_Total)\% usage"
|
|
[hashtable]$Initial = @{};
|
|
[hashtable]$MemoryData = @{};
|
|
|
|
foreach ($item in $MemoryPercent.Keys) {
|
|
$Initial.Add($item, $MemoryPercent[$item]);
|
|
}
|
|
|
|
$MemoryData.Add('Memory Available Bytes', [decimal]($Initial.'\Memory\Available Bytes'.value));
|
|
$MemoryData.Add('Memory Total Bytes', (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory);
|
|
$MemoryData.Add('Memory Used Bytes', $MemoryData.'Memory Total Bytes' - $MemoryData.'Memory Available Bytes');
|
|
$MemoryData.Add('Memory Used %', $MemoryData.'Memory Available Bytes' / $MemoryData.'Memory Total Bytes' * 100);
|
|
$MemoryData.Add('PageFile %', $Initial.'\Paging File(_Total)\% usage'.value);
|
|
|
|
return $MemoryData;
|
|
} |