0

I'm aware of the Microsoft.WindowsAzure.Diagnostics performance monitoring. I'm looking for something more real-time though like using the System.Diagnostics.PerformanceCounter The idea is that a the real-time information will be sent upon a AJAX request.

Using the performance counters available in azure: http://msdn.microsoft.com/en-us/library/windowsazure/hh411520

The following code works (or at least in the Azure Compute Emulator, I haven't tried it in a deployment to Azure):

    protected PerformanceCounter FDiagCPU = new PerformanceCounter("Processor", "% Processor Time", "_Total");
    protected PerformanceCounter FDiagRam = new PerformanceCounter("Memory", "Available MBytes");
    protected PerformanceCounter FDiagTcpConnections = new PerformanceCounter("TCPv4", "Connections Established");

Further down in the MSDN page is another counter I would like to use: Network Interface(*)\Bytes Received/sec

I tried creating the performance counter:

protected PerformanceCounter FDiagNetSent = new PerformanceCounter("Network Interface", "Bytes Received/sec", "*");

But then I receive an exception saying that "*" isn't a valid instance name.

This also doesn't work:

protected PerformanceCounter FDiagNetSent = new PerformanceCounter("Network Interface(*)", "Bytes Received/sec");

Is using performace counters directly in Azure frowned upon?

riaanc.
  • 45
  • 4

1 Answers1

1

The issue you're having here isn't related to Windows Azure, but to performance counters in general. As the name implies, Network Interface(*)\Bytes Received/sec is a performance counter for a specific network interface.

To initialize the performance counter, you'll need to initialize it with the name of the instance (the network interface) you'll want to get the metrics from:

var counter = new PerformanceCounter("Network Interface",
        "Bytes Received/sec", "Intel[R] WiFi Link 1000 BGN");

As you can see from the code, I'm specifying the name of the network interface. In Windows Azure you don't control the server configuration (the hardware, the Hyper-V virtual network card, ...), so I wouldn't advise on using the name of the network interface.

That's why it might be safer to enumerate the instance names to initialize the counter(s):

var category = new PerformanceCounterCategory("Network Interface");
foreach (var instance in category.GetInstanceNames())
{
    var counter = new PerformanceCounter("Network Interface",
                                               "Bytes Received/sec", instance);
    ...
}
Sandrino Di Mattia
  • 24,739
  • 2
  • 60
  • 65