views:

23

answers:

1

I have a lot of HTTPHandlers in my server code.
How can I monitor performance of my web server in Live?
I need the next statistics:
1. Requests per second (of each handler or summary)
2. CPU-usage

Thanks in advance

+5  A: 

Hi

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.

Pankaj Mishra