0

Is there a way to get the RAM Utilization with powershell/Python, without the cached ram? We want to monitor the utilization of our System parameters. At the moment I use this in powershell, which gets calles by task scheduler every 30 minutes together with other parameter checks:

...
$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
...

which will then be sent to a Monitoring application of us.

How can we get RAM without Cache? Is there a way?

InfiProg
  • 13
  • 1
  • 2
  • Yes, but you will have to do some work to get the raw data into MBs /GBs. Look into `Get-Counter -ListSet *memory* | Select-Object -ExpandProperty Counter` to list all which will list all performance data property names you can use to get the info you need. Such as: `Get-Counter '\Memory\Available MBytes'` – Abraham Zinala Apr 06 '21 at 13:28
  • I have mine set up for GPU monitoring that gets the information off my miners to let me know when one goes does – Abraham Zinala Apr 06 '21 at 13:28
  • With the '''Get-Counter -ListSet *memory* | Select-Object -ExpandProperty Counter''', I can only find '''GPU Memory''' and '''.NET Memory Cache''' for example. I can't find ''' Memory\Available MBytes '''. Then I get the message, the object hasn't been found on the computer – InfiProg Apr 06 '21 at 14:46
  • Are you adding the wildcards? – Abraham Zinala Apr 06 '21 at 15:07
  • Yes, I enter ```Get-Counter '\Memory\Available MBytes'``` – InfiProg Apr 06 '21 at 15:11
  • `Get-Counter -ListSet *memory* | Select-Object -ExpandProperty Counter` paste your results from this – Abraham Zinala Apr 06 '21 at 15:38
  • Results are ```\GPU Local Adapter Memory(*)\Local Usage \GPU Adapter Memory(*)\Shared Usage \GPU Adapter Memory(*)\Dedicated Usage \GPU Adapter Memory(*)\Total Committed \GPU Process Memory(*)\Shared Usage \GPU Process Memory(*)\Dedicated Usage \GPU Process Memory(*)\Non Local Usage \GPU Process Memory(*)\Local Usage \GPU Process Memory(*)\Total Committed \GPU Non Local Adapter Memory(*)\Non Local Usage ``` – InfiProg Apr 09 '21 at 10:39
  • AND ```\.NET Memory Cache 4.0(*)\Cache Hits \.NET Memory Cache 4.0(*)\Cache Misses \.NET Memory Cache 4.0(*)\Cache Hit Ratio \.NET Memory Cache 4.0(*)\Cache Trims \.NET Memory Cache 4.0(*)\Cache Entries \.NET Memory Cache 4.0(*)\Cache Turnover Rate``` – InfiProg Apr 09 '21 at 10:39

0 Answers0