2016-04-14 26 views
0

我一直在對此進行深入研究。我覺得我很接近,但我在試圖展示WS時遇到了麻煩。Tomcat的PowerShell內存使用情況

我沒找到什麼似乎顯示每個應用程序的內存

http://www.lmftfy.com/index.php/powershell-get-memory-used-by-a-group-of-processes/

https://foobarcode.wordpress.com/2014/12/12/memory-usage-grouped-by-process-name/

ps tomcat* -ComputerName computerA | Group ProcessName | Select @{Label="Mem";Expression={($_.group |Measure WorkingSet -sum).Sum/1MB }} | Sort Mem 

非常相關的,這工作得很好。

$procs = get-process tomcat* -ComputerName computerA 
    foreach ($proc in $procs){ 
    $WorkingSet = '{0:N0}' -f [int](Group ProcessName | Select (@{Label="Mem";Expression={($proc.group |Measure WorkingSet -sum).Sum/1MB }})) 
    $VirtualMem = '{0:N0}' -f [int]($proc.VM/1MB) 
     write-host 'WS' $WorkingSet 
     write-host 'VM' $VirtualMem 
} 

我們知道WS是不是0 ..

我想我有一個格式問題與:

Mem 
--- 
4.109375 
1006.9453125 
1388.453125 

所以......我們通過大量的計算機要循環WS ..

WS 0 
VM 1,523 
WS 0 
VM 60 
WS 0 
VM 1,917 

我以爲我是在這個非常接近..

$procs = get-process tomcat* -ComputerName computerA 
    foreach ($proc in $procs){ 
    $name = $proc.MachineName 
    $process = $proc.ProcessName 
    $WorkingSet = '{0:N0}' -f [int]($proc.WS/1MB) 
    $VirtualMem = '{0:N0}' -f [int]($proc.VM/1MB) 
    write-host $name $process 'WS' $WorkingSet 'VM' $VirtualMem 
} 

但是,使用此當我得到負值..

Tomcat Memory Usage Report - 04/14/2016       
# Server Process ID (PID) Process Name Working Set(Kb) Virtual Memory(Mb) 
25 Server24 5876 tomcat6 1,471 -251  
26 Server25 5832 tomcat6 -1,536 -1,118 
27 Server26 1824 tomcat6 -1,497 -1,133 
28 Server27 7916 tomcat6 1,661 -1,013 
29 Server28 6340 tomcat6 888 1,690 
30 Server29 6700 tomcat6 -1,242 1,611 
31 Server30 9880 Tomcat6 1,007 1,523 

回答

0

這是否幫助任何?

(Get-Counter -ListSet Process | Get-Counter) | 
Where {$_.InstanceName -eq 'TomCat' -and $_.path -like '*working set*'} 
0

您應該使用$proc.workingset64,如果你在64位系統上得到負值