0

Microsoft.WindowsAzure.Diagnostics のパフォーマンス監視については認識しています。System.Diagnostics.PerformanceCounter を使用するなど、よりリアルタイムなものを探しています。アイデアは、AJAX 要求でリアルタイム情報が送信されるということです。

Azure で利用可能なパフォーマンス カウンターの使用: http://msdn.microsoft.com/en-us/library/windowsazure/hh411520

次のコードは機能します (または、少なくとも Azure コンピューティング エミュレーターでは、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 でパフォーマンス カウンターを直接使用することは嫌われていますか?

4

1 に答える 1

1

ここで発生している問題は、Windows Azure に関連するものではなく、一般的なパフォーマンス カウンターに関連するものです。名前が示すように、Network Interface(*)\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);
    ...
}
于 2012-05-14T10:47:04.883 に答える