0

有没有办法在没有缓存的 ram 的情况下使用 powershell/Python 获得 RAM 利用率?我们要监控系统参数的使用情况。目前我在powershell中使用它,它每30分钟被任务调度程序调用一次以及其他参数检查:

...
$counts = 6
$Samples = 145
for($j=0; $j -lt $counts; $j++){
    $temp = 0
    $result = 0
    for ($i=0; $i -lt $Samples; $i++){
        $os = Get-WMIObject Win32_OperatingSystem
        $os | select *memory*
        $pctUsed = [math]::Round(100-($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
        $temp = $pctUsed + $temp
        Start-Sleep -s 2
    }
$result = $temp/$Samples
...

然后将其发送到我们的监控应用程序。

我们如何在没有缓存的情况下获得 RAM?有办法吗?

4

0 回答 0