开发者

Get number of requests in IIS from c# code

I am looking to get the number of requests that IIS currently has queued开发者_Go百科, programatically, in C#.

I'll also be looking to get the CPU usage as well...

Can anyone point me in the right direction?


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.


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 :)


Take a look at the System.Diagnostics namespace, especially the classes that start with PerformanceCounterXXX

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜