This is something that's always bothered me, so I'll ask the Server Fault community.
I love Process Explorer for keeping track of more than just the high-level tasks you get in the Task Manager. But I constantly want to know which of those dozen services hosted in a single process under svchost is making my processor spike.
So... is there any non-intrusive way to find this information out?
Yes, there is an (almost) non-intrusive and easy way:
Split each service to run in its own SVCHOST.EXE process and the service consuming the CPU cycles will be easily visible in Process Explorer (the space after "=" is required):
Do this in a command line window or put it into a BAT script. Administrative privileges are required and a restart of the computer is required before it takes effect.
The original state can be restored by:
Example: to make Windows Management Instrumentation run in a separate SVCHOST.EXE:
This technique has no ill effects, except perhaps increasing memory consumption slightly. And apart from observing CPU usage for each service it also makes it easy to observe page faults delta, disk I/O read rate and disk I/O write rate for each service. For Process Explorer, menu View/Select Columns: tab Process Memory/Page Fault Delta, tab Process Performance/IO Delta Write Bytes, tab Process Performance/IO Delta Read Bytes, respectively.
On most systems there is only one SVCHOST.EXE process that has a lot of services. I have used this sequence (it can be pasted directly into a command line window):
While I don't know of easy way to do it directly, you can often infer it from the Process Explorer properties page for the svchost process. The Services tab on the process properties will tell you which services are hosted in that process. And the Threads tab will show you the threads and thread stacks running as well as their CPU usage. Often the Start Address on the thread will give an indication of the entry point DLL, and by extension the service, that's running on that thread. Other times you can look at the thread callstack and will see the module name in the call stack that tells you which piece of code is running.
Try Service Disclosure tool. It:
Your comments and suggestions are welcome.
@Peter Mortensen: Thanks for idea.
In Powershell, you can do this for all non-lsass services using the following commands:
The list that is excluded here all need to run in a shared lsass.exe, with the exception of policyagent, which is required for the group policy agent to communicate properly during boot.
Also recently discovered that was (Process Activation) and w3svc (IIS World Wide Web) need to share their processes, so they have been added to the exclusions.
This has been tested on Windows 10 (1607, build 14393.953), the exclusions are different in XP, ....
I don't know if this is still a question you want answers, but while troubleshooting a customer's svchost error, I learned that there is a command line for exactly this: "tasklist /svc" It gives a complete list of the processes running, with the process ID and the services each process is running. It doesn't give a processor usage, but you can close them one process at a time by process ID, and learn at least which group of services is clogging up your CPU.
Nowdays, you can use PowerShell to change the service types to "Own Process" and see the memory for each one individually. This Gist show the complete code. The central idea is trying to change the service type from the least intrusive to the most intrusive way:
When putting the
Set-ServiceTypeToOwnProcess.ps1
andEnable-Privilege.ps1
files in the same folder, you can execute the script like this: