Problem
Usually during diagnostic measurements or procedures we have to identify which system process corresponds to our Sitecore instance. Fortunately we know that all ASP.NET processes are named w3wp and this makes life simpler. But when we have a few instances run simultaneously, it become a tricky task to figure out what exact one we should pick.Each process has its unique assigned during the process creation. Almost all the diagnostics tools show process name along with process ID (PID later) so it would be enough to know the exact PID to solve this task.
This article will demonstrate a few possible approaches.
1. Use the Command Line arguments.
This is a straightforward way and it doesn't require any special tools. Usually w3wp process is started with additional command line arguments, where one of such argument is application pool name. So all we need here is just to extract the name of application pool and compare it with instance we are looking for.
We can use either the Task Manager (enable the PID and Command Line columns) or any other tool (e.g. Process Hacker, Process Explorer) to see the command line arguments and PIDs simultaneously.
For instance the arguments for w3wp process are be following:
c:\windows\system32\inetsrv\w3wp.exe -ap "sc660rev130111" -v "v2.0" -l "webengine4.dll" -a \\.\pipe\iisipm222a26dd-7290-47e0-b6ec-92d2cbb9846e -h "C:\inetpub\temp\apppools\sc660rev130111\sc660rev130111.config" -w "" -m 0 -t 20 -ta 0
We might note that name of application pool is "sc660rev130111". If we compare this name with PID of w3wp process we would be able to identify the process.
Disadvantages:
- Command outputs application pool names instead of site names. So sometimes this will require additional checks.
2. Reset IIS
This is the simplest way. We just need to reset IIS (through UI or through command line by using the iisreset command) and request any page that belongs to our instance. By doing so we'll have only one w3wp process and any ambiguous will be impossible.
Disadvantages:
- This approach downs all the sites. Very often this is not what want so this way is suitable only in very rare cases.
3. Use appcmd.exe shipped with IIS
This approach is more elegant because it doesn't require IIS recycles. In order to use it:- Open command line.
- Type %systemroot%\System32\inetsrv\appcmd.exe list wp
The output will look like:
Here we can see the PIDs mapped to application pool names. Having this it's much easier to understand which process we want to have a deal with.
More info about appcmd tool here can be found here: http://technet.microsoft.com/en-us/library/cc772200(v=ws.10).aspx
Disadvantages:
- This approach is applicable only to IIS 7 and higher.
- Command outputs application pool names instead of site names. So sometimes this will require additional checks.
- Command requires administrator rights, so we should run command line as administrator.
4. Use Process ID value
During instance startup Sitecore writes its PID to log file. So in order to get actual instance's PID we should just find the latest log file that covers startup and extract number from body. The line that shows PID looks as follows:9028 13:46:52 INFO Microsoft.NET version 4.0.30319.18051
9028 13:46:52 INFO
9028 13:46:52 INFO Process id: 7176
9028 13:46:52 INFO Windows identity used by the process: NT AUTHORITY\NETWORK SERVICE. Impersonation: False
9028 13:46:52 INFO Managed pipeline mode: Integrated
Note that in case of CMS 7 we need to refer to general log file rather than to specialized one (i.e. to log.{date}.{time} rather than to Search.log.{date}.{time} or Crawling.log.{date}.{time}).
Disadvantages:
- If instance is run for a while it takes some time to find which log file covers the latest instance startup.
5. Identifying process in Performance Monitor
By default Performance Monitor doesn't display PIDs, so if we have name collisions its impossible to identify which exact instance corresponds to particular process.To handle this we may refer to the article below which describes how to enable PID displaying for objects:
http://support.microsoft.com/kb/281884
Even after the PID displaying is enabled, some counters provide us with Application Pool ID rather than with PID. For instance:
1. Identify PID using any way described above.
2. Download and run Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx).
3. Open w3wp.exe with PID from point 1 and check what application pools it contains:
From this we may easily identify that _LM_W3SVC_10_ROOT pool belongs to PID 7176. So now we know which one to choose in Performance Monitor.
No comments:
Post a Comment