Tomcat 的 PowerShell 内存使用情况

标签 powershell tomcat memory grouping

我一直在研究这个问题。我认为非常接近,但我在尝试显示 WS 时遇到了问题。

我确实发现与显示每个应用程序的内存非常相关

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

这很好用。

Mem
---
4.109375
1006.9453125
1388.453125

所以...我们想遍历多台计算机:

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

我想我的 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   

最佳答案

这有什么帮助吗?

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

关于Tomcat 的 PowerShell 内存使用情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36632719/

相关文章:

tomcat - 节点在 SOLR 中关闭后未选出领导者

ios - 我如何找到一个结构占用了多少内存?

powershell - 在新线程powershell中调用函数

asp.net - 无法提交配置更改,因为文件在磁盘上已更改

windows - $LastExitCode=0,但 $?=False 在 PowerShell 中。将 stderr 重定向到 stdout 会给出 NativeCommandError

powershell - 如何使用具有集成安全性的 Powershell 连接 Azure Paas 数据库

tomcat - 域访问 Web 应用程序 - Tomcat

eclipse - 将 Maven Web 应用程序运行到 Tomcat

python - 尝试读取大型网站文件数据时出现 MemoryError 异常

c++ - std::unordered_map::reserve 是否保证只要映射中的元素较少就不会发生内存分配?