title: Performance counters, changing process IDs?
body: <p>I am creating performance counters for the running websites on windows 2008 and IIS 7, so the processes are on the form of (i.e. W3WP for the first application pool, W3WP#1 for the second application pool, W3WP#2 for the third application pool, etc.)</p>
  
  <p><strong>The question is</strong>: What will happen if the application pools were recycled, or the machine was restarted? Will the same processes instances be mapped to the same app pools or they will change? (i.e. will w3wp be assigned to the first application pool, w3wp#1 for the second pool, w3wp#2 for the third application pool, etc.)</p>
  
  <p>And, if the pool-process association will change, how can we keep monitoring the same application pool without having to reconfigure the performance counters every time the system recycles? </p>
  
  <p><strong>To clarify:</strong>
  The performance counters I am referring to are not the ASP.Net counters, these have the app pool name associated with the counter. </p>
  
  <p>Here, I am referring to counters like the "Process", and .Net framework counters such as the ".Net CLR Memory" and ".Net CLR Exception" counters, these don't use the app pool, they use the process name, here is an example "\Process(w3wp)\Thread Count" is a performance counter that tells the # of threads in the process w3wp. This process is the worker process for one of the app pools. "\Process(w3wp#1)\Thread Count" does the same but for the worker process of another pool.</p>
  
  <p>The question is: if the pools recycle or the machine recycles, will w3wp and w3wp#1 represent the same pools or not, and if not, how can we guarantee that we continue monitoring the pools that we want without the need to reconfigure the performance counters?</p>