icinga-powershell-framework/lib/provider/memory/Get-IcingaMemoryPerformanceCounter.psm1

21 lines
836 B
PowerShell
Raw Normal View History

2019-07-25 12:29:21 -04:00
function Get-IcingaMemoryPerformanceCounter()
{
$MemoryPercent = New-IcingaPerformanceCounterArray -Counter "\Memory\% committed bytes in use","\Memory\committed bytes","\Paging File(_Total)\% usage"
2019-07-25 12:29:21 -04:00
[hashtable]$Result = @{};
foreach ($item in $MemoryPercent.Keys) {
$Result.Add($item, $MemoryPercent[$item]);
2019-07-25 12:29:21 -04:00
}
return $Result;
}
function Get-IcingaMemoryPerformanceCounterFormated()
{
[hashtable]$Result = @{};
$Result.Add('Memory %', (Get-IcingaMemoryPerformanceCounter).'\Memory\% committed bytes in use'.value);
$Result.Add('Memory GigaByte', (ConvertTo-GigaByte ([decimal](Get-IcingaMemoryPerformanceCounter).'\Memory\committed bytes'.value) -Unit Byte));
$Result.Add('PageFile %', (Get-IcingaMemoryPerformanceCounter).'\Paging File(_Total)\% usage'.value);
return $Result;
}