Reputation: 165
I am looking to get the number of requests that IIS currently has queued, programatically, in C#.
I'll also be looking to get the CPU usage as well...
Can anyone point me in the right direction?
Upvotes: 10
Views: 3199
Reputation: 20693
On IIS7 you could use Microsoft.Web.Administration assembly, WorkerProcess object has GetRequests method, look at WorkerProcess.GetRequests Method
And for CPU usage you could use Microsoft.Web.Administration.ApplicationPoolCpu property of ApplicationPool class, alltough I am not sure that there are information about current CPU usage, look at ApplicationPool.Cpu
Microsoft.Web.Administration is great :)
Upvotes: 2
Reputation: 63136
You will want to look at reading information from the performance counters of the system, depending on what you are looking for there are a number of counters that you can use.
This MSDN article shows all IIS6 performance counters there is a similar one for IIS7 that you should be able to find.
For the CPU usage, there are a few ways you can go about this as well. Depending on if you want total CPU usage, or a per-process CPU usage.
Also, here is a tutorial on reading from the process counter.
Upvotes: 4
Reputation: 30912
Take a look at the System.Diagnostics
namespace, especially the classes that start with PerformanceCounterXXX
Upvotes: 1