2010-03-16 72 views
3

我的服務器代碼中有很多HTTPHandlers。
如何監視Live中我的Web服務器的性能?
我需要在下一個統計:
1.每秒請求
2. CPU使用率(每個處理器或摘要的)ASP.NET Live活動監視器

在此先感謝

回答

6

請嘗試這些鏈接和這些行代碼此一定會幫助你。

http://www.codeproject.com/KB/dotnet/perfcounter.aspx http://www.aspheute.com/english/20000809.asp http://www.csharphelp.com/2006/05/performance-monitoring/

可以使用PerformanceCounter類從System.Diagnostics

PerformanceCounter cpuCounter; 
PerformanceCounter ramCounter; 

cpuCounter = new PerformanceCounter(); 

cpuCounter.CategoryName = "Processor"; 
cpuCounter.CounterName = "% Processor Time"; 
cpuCounter.InstanceName = "_Total"; 

ramCounter = new PerformanceCounter("Memory", "Available MBytes"); 


public string getCurrentCpuUsage(){ 
      cpuCounter.NextValue()+"%"; 
} 

public string getAvailableRAM(){ 
      ramCounter.NextValue()+"MB"; 
} 

這些所有的事情都會解決您的問題。