ASP.NET Live activity monitor
I have a lot of HTTPHandlers in my server code.
How can I monitor performance of my we开发者_如何学运维b server in Live? I need the next statistics: 1. Requests per second (of each handler or summary) 2. CPU-usageThanks in advance
Please try these links and these line of code this will surely help you.
http://www.codeproject.com/KB/dotnet/perfcounter.aspx http://www.aspheute.com/english/20000809.asp http://www.csharphelp.com/2006/05/performance-monitoring/
You can use the PerformanceCounter class from 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";
}
These all things will solve your problem.
精彩评论