我的服务器代码中有很多 HTTPHandler。
如何在 Live 中监控我的 Web 服务器的性能?
我需要下一个统计信息:
1. 每秒请求数(每个处理程序或摘要)
2. CPU 使用率
提前致谢
请尝试这些链接和这些代码行,这肯定会对您有所帮助。
http://www.codeproject.com/KB/dotnet/perfcounter.aspx http://www.aspheute.com/english/20000809.asp http://www.csharphelp.com/2006/05/performance-monitoring/
您可以使用System.Diagnostics中的PerformanceCounter类:
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";
}
这些都可以解决你的问题。