问题定义:我们在基本上是一个服务器的web服务器上做了一些配置级别的更改。我们已经将线程数量从默认的300个增加到了大约450个。
这种变化可能会使我们的服务器崩溃。
因此,我们希望监视工作线程,并希望定期将其记录到数据库中。
我的进展到目前为止:
到目前为止,我能够通过下面提到的Powershell命令运行一个exe来获得详细信息。
(只需将w3wp.exe替换为任何进程名即可获得结果)
$name = "w3wp.exe"
$processHandle = (Get-CimInstance Win32_Process -Filter "Name = '$name'").ProcessId
$Threads = Get-CimInstance -Class Win32_Thread -Filter "ProcessHandle = $processHandle"
$threads | Select-Object priority, thread*, User*Time, kernel*Time |
Out-GridView -Title "The $name process has $($threads.count) threads"问题:在上面提到的脚本中,当w3wp.exe使用多个PID运行时,无法给出exes的结果。
有什么方法可以让我们得到多个前男友的结果吗?
表应该是
处理器名称\PID\##.丝线科
发布于 2017-04-03 12:07:29
因此,我在运行您的代码时遇到了一个错误,我希望您也能得到它。
一行中的无效查询:3字符:12+ $Threads = Get-CimInstance Win32_Thread -Filter "ProcessHandle .+~+ CategoryInfo : InvalidArgument:(:) Get-CimInstance,CimException + FullyQualifiedErrorId : HRESULT 0x80041017,ProcessHandle.
这是有意义的因为-Filter看起来是这样的..。就像我用chrome.exe做测试一样。这是无效的。
ProcessHandle = 7224 7420 8688 8800 8916 460 10884 7340 10956 6756 14604 13260 9588 18020 22264 11516 17684 12664因此,我只是添加了一个循环,以允许多个$processHandle,它似乎工作得很好。
$Threads = $processHandle | Foreach-Object{
Get-CimInstance -Class Win32_Thread -Filter "ProcessHandle = $_"
}https://stackoverflow.com/questions/43182674
复制相似问题