我知道Microsoft.WindowsAzure.Diagnostics性能监控。我正在寻找更实时的东西,虽然像使用System.Diagnostics.PerformanceCounter一样,其想法是实时信息将在AJAX请求时发送。
使用azure中提供的性能计数器:http://msdn.microsoft.com/en-us/library/windowsazure/hh411520
以下代码可以工作(或者至少在Azure Compute Emulator中,我还没有在部署到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");在MSDN页面的更下面是我想使用的另一个计数器: Network Interface(*)\Bytes Received/sec
我尝试创建性能计数器:
protected PerformanceCounter FDiagNetSent = new PerformanceCounter("Network Interface", "Bytes Received/sec", "*");但是之后我收到一个异常,说"*“不是一个有效的实例名。
这也不起作用:
protected PerformanceCounter FDiagNetSent = new PerformanceCounter("Network Interface(*)", "Bytes Received/sec");在Azure中直接使用性能计数器是否不受欢迎?
发布于 2012-05-14 18:47:05
你在这里遇到的问题与Windows Azure无关,但通常与性能计数器有关。顾名思义,网络接口(*)\Bytes Received/sec是特定网络接口的性能计数器。
要初始化性能计数器,您需要使用要从中获取指标的实例(网络接口)的名称对其进行初始化:
var counter = new PerformanceCounter("Network Interface",
"Bytes Received/sec", "Intel[R] WiFi Link 1000 BGN");正如您从代码中看到的,我指定了网络接口的名称。在Windows Azure中,您不能控制服务器配置(硬件、Hyper-V虚拟网卡等),因此我不建议使用网络接口的名称。
这就是为什么枚举实例名来初始化计数器更安全的原因:
var category = new PerformanceCounterCategory("Network Interface");
foreach (var instance in category.GetInstanceNames())
{
var counter = new PerformanceCounter("Network Interface",
"Bytes Received/sec", instance);
...
}https://stackoverflow.com/questions/10581029
复制相似问题