WmiWebEventProvider クラス
アセンブリ: System.Web (system.web.dll 内)


運用および操作の担当者は、ASP.NET Health Monitoring を使用して、配置されている Web アプリケーションを管理できます。System.Web.Management 名前空間には、アプリケーションの状態データをパッケージ化する状態イベント型、およびそのデータを処理するプロバイダ型が含まれます。また、状態イベント管理を支援するサポート型も含まれます。
ASP.NET では、このクラスを使用して状態監視イベントを WMI イベントに割り当てます。ASP.NET 状態監視イベントが WMI サブシステムに伝達されるようにするには、WmiWebEventProvider を構成する必要があります。構成するには、構成ファイルの healthMonitoring セクションに適切な設定を追加します。
Aspnet.mof ファイルに格納されている情報には、ASP.NET 状態監視イベントが WmiWebEventProvider に伝達されて WMI イベントに割り当てられると発生する、WMI イベントのパラメータが記述されています。Aspnet.mof file ファイルは、.NET Framework のビルド ディレクトリの、たとえば %Systemroot%\Microsoft.NET\Framework\BuildNumber に格納されています。状態監視イベントの WMI イベントへの割り当ての詳細については、「WMI による ASP.NET Health Monitoring イベントの配信」を参照してください。
![]() |
---|
ほとんどの場合、ASP.NET 状態監視型は実装のまま使用でき、healthMonitoring 構成セクションに値を指定して ASP.NET Health Monitoring system を制御できます。状態監視型の派生として独自のイベントおよびプロバイダを作成することもできます。カスタム プロバイダの作成例については、「方法 : 状態監視のカスタム プロバイダの例を実装する」を参照してください。 |

Web アプリケーション状態イベントの発生に伴い ASP.NET Health Monitoring が発生させる WMI イベントのコンシューマの作成手順を示すコード例を次に示します。また、WmiWebEventProvider の構成方法を示す構成ファイルの抜粋も示します。この例では、この構成によりすべての Web イベントが標準 WmiWebEventProvider にディスパッチされます。
![]() |
---|
監視する WmiWebEventProvider 型および状態イベント型は、既定で構成済みです。構成する必要があるのは、すべての状態イベントに適用される規則の定義だけです。状態イベントは既定では WmiWebEventProvider にディスパッチされないことに注意してください。 |
次の構成ファイルの抜粋に、healthMonitoring セクションの構成を示します。これにより、ASP.NET は WmiWebEventProvider を使用してすべての状態監視イベントを処理できます。
<healthMonitoring>
<rules>
</healthMonitoring>
Imports System Imports System.Management ' Capture WMI events associated with ' ASP.NET health monitoring types. Class SampleWmiWebEventListener 'Displays event related information. Shared Sub DisplayEventInformation(ByVal ev _ As ManagementBaseObject) ' It contains the name of the WMI raised ' event. This is the name of the ' event class as defined in the ' Aspnet.mof file. Dim eventTypeName As String ' Get the name of the WMI raised event. eventTypeName = ev.ClassPath.ToString() ' Process the raised event. Select Case eventTypeName ' Process the heartbeat event. Case "HeartBeatEvent" Console.WriteLine("HeartBeat") Console.WriteLine(vbTab + _ "Process: {0}", ev("ProcessName")) Console.WriteLine(vbTab + "App: {0}", _ ev("ApplicationUrl")) Console.WriteLine(vbTab + "WorkingSet: {0}", _ ev("WorkingSet")) Console.WriteLine(vbTab + "Threads: {0}", _ ev("ThreadCount")) Console.WriteLine(vbTab + "ManagedHeap: {0}", _ ev("ManagedHeapSize")) Console.WriteLine(vbTab + "AppDomainCount: {0}", _ ev("AppDomainCount")) ' Process the request error event. Case "RequestErrorEvent" Console.WriteLine("Error") Console.WriteLine("Url: {0}", _ ev("RequestUrl")) Console.WriteLine("Path: {0}", _ ev("RequestPath")) Console.WriteLine("Message: {0}", _ ev("EventMessage")) Console.WriteLine("Stack: {0}", _ ev("StackTrace")) Console.WriteLine("UserName: {0}", _ ev("UserName")) Console.WriteLine("ThreadID: {0}", _ ev("ThreadAccountName")) ' Process the application lifetime event. Case "ApplicationLifetimeEvent" Console.WriteLine("App Lifetime Event {0}", _ ev("EventMessage")) ' Handle events for which processing is not ' provided. Case Else Console.WriteLine("ASP.NET Event {0}", _ ev("EventMessage")) End Select End Sub 'DisplayEventInformation ' End DisplayEventInformation. ' The main entry point for the application. Shared Sub Main(ByVal args() As String) ' Get the name of the computer on ' which this program runs. ' Note. The monitored application must also run ' on this computer. Dim machine As String = Environment.MachineName ' Define the Common Information Model (CIM) path ' for WIM monitoring. Dim path As String = _ String.Format("\\{0}\root\aspnet", machine) ' Create a managed object watcher as ' defined in System.Management. Dim query As String = "select * from BaseEvent" Dim watcher As New ManagementEventWatcher(query) ' Set the watcher options. Dim timeInterval As New TimeSpan(0, 1, 30) watcher.Options = _ New EventWatcherOptions(Nothing, timeInterval, 1) ' Set the scope of the WMI events to ' watch to be ASP.NET applications. watcher.Scope = _ New ManagementScope(New ManagementPath(path)) ' Set the console background. Console.BackgroundColor = ConsoleColor.Blue ' Set foreground color. Console.ForegroundColor = ConsoleColor.Yellow ' Clear the console. Console.Clear() ' Loop indefinitely to catch the events. Console.WriteLine( _ "Listener started. Enter CntlC to terminate") While True Try ' Capture the WMI event related to ' the Web event. Dim ev As ManagementBaseObject = _ watcher.WaitForNextEvent() ' Display the Web event information. DisplayEventInformation(ev) ' Prompt the user. Console.Beep() Catch e As Exception Console.WriteLine("Error: {0}", e) Exit While End Try End While End Sub 'Main End Class 'SampleWmiWebEventListener
using System; using System.Management; namespace SamplesAspNet { // Capture WMI events associated with // ASP.NET health monitoring types. class SampleWmiWebEventListener { //Displays event related information. static void DisplayEventInformation( ManagementBaseObject ev) { // It contains the name of the WMI raised // event. This is the name of the // event class as defined in the // Aspnet.mof file. string eventTypeName; // Get the name of the WMI raised event. eventTypeName = ev.ClassPath.ToString(); // Process the raised event. switch (eventTypeName) { // Process the heartbeat event. case "HeartBeatEvent": Console.WriteLine("HeartBeat"); Console.WriteLine("\tProcess: {0}", ev["ProcessName"]); Console.WriteLine("\tApp: {0}", ev["ApplicationUrl"]); Console.WriteLine("\tWorkingSet: {0}", ev["WorkingSet"]); Console.WriteLine("\tThreads: {0}", ev["ThreadCount"]); Console.WriteLine("\tManagedHeap: {0}", ev["ManagedHeapSize"]); Console.WriteLine("\tAppDomainCount: {0}", ev["AppDomainCount"]); break; // Process the request error event. case "RequestErrorEvent": Console.WriteLine("Error"); Console.WriteLine("Url: {0}", ev["RequestUrl"]); Console.WriteLine("Path: {0}", ev["RequestPath"]); Console.WriteLine("Message: {0}", ev["EventMessage"]); Console.WriteLine("Stack: {0}", ev["StackTrace"]); Console.WriteLine("UserName: {0}", ev["UserName"]); Console.WriteLine("ThreadID: {0}", ev["ThreadAccountName"]); break; // Process the application lifetime event. case "ApplicationLifetimeEvent": Console.WriteLine("App Lifetime Event {0}", ev["EventMessage"]); break; // Handle events for which processing is not // provided. default: Console.WriteLine("ASP.NET Event {0}", ev["EventMessage"]); break; } } // End DisplayEventInformation. // The main entry point for the application. static void Main(string[] args) { // Get the name of the computer on // which this program runs. // Note. The monitored application must also run // on this computer. string machine = Environment.MachineName; // Define the Common Information Model (CIM) path // for WIM monitoring. string path = String.Format("\\\\{0}\\root\\aspnet", machine); // Create a managed object watcher as // defined in System.Management. string query = "select * from BaseEvent"; ManagementEventWatcher watcher = new ManagementEventWatcher(query); // Set the watcher options. TimeSpan timeInterval = new TimeSpan(0, 1, 30); watcher.Options = new EventWatcherOptions(null , timeInterval, 1); // Set the scope of the WMI events to // watch to be ASP.NET applications. watcher.Scope = new ManagementScope(new ManagementPath(path)); // Set the console background. Console.BackgroundColor = ConsoleColor.Blue; // Set foreground color. Console.ForegroundColor = ConsoleColor.Yellow; // Clear the console. Console.Clear(); // Loop indefinitely to catch the events. Console.WriteLine( "Listener started. Enter CntlC to terminate"); while (true) { try { // Capture the WMI event related to // the Web event. ManagementBaseObject ev = watcher.WaitForNextEvent(); // Display the Web event information. DisplayEventInformation(ev); // Prompt the user. Console.Beep(); } catch (Exception e) { Console.WriteLine("Error: {0}", e); break; } } } } }

System.Configuration.Provider.ProviderBase
System.Web.Management.WebEventProvider
System.Web.Management.WmiWebEventProvider


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WmiWebEventProvider コンストラクタ
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタは、ASP.NET Health Monitoring system によって内部的に使用されます。TraceWebEventProvider オブジェクトのインスタンス化には使用しませんが、このクラスを継承する独自のプロバイダ型を実装する場合には呼び出すことができます。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WmiWebEventProvider プロパティ

名前 | 説明 | |
---|---|---|
![]() | Description | 管理ツールまたは他のユーザー インターフェイス (UI) での表示に適した、簡単でわかりやすい説明を取得します。 ( ProviderBase から継承されます。) |
![]() | Name | 構成時にプロバイダを参照するために使用される表示名を取得します。 ( ProviderBase から継承されます。) |

WmiWebEventProvider メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | Flush | オーバーライドされます。 すべてのイベントをプロバイダのバッファから削除します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | Initialize | オーバーライドされます。 このオブジェクトの初期値を設定します。 |
![]() | ProcessEvent | オーバーライドされます。 プロバイダに渡されたイベントを処理します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | Shutdown | オーバーライドされます。 プロバイダのシャットダウンに関連するタスクを実行します。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

WmiWebEventProvider メンバ
ASP.NET 状態監視イベントを WMI (Windows Management Instrumentation) イベントに割り当てるイベント プロバイダを実装します。
WmiWebEventProvider データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Description | 管理ツールまたは他のユーザー インターフェイス (UI) での表示に適した、簡単でわかりやすい説明を取得します。(ProviderBase から継承されます。) |
![]() | Name | 構成時にプロバイダを参照するために使用される表示名を取得します。(ProviderBase から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | Flush | オーバーライドされます。 すべてのイベントをプロバイダのバッファから削除します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | Initialize | オーバーライドされます。 このオブジェクトの初期値を設定します。 |
![]() | ProcessEvent | オーバーライドされます。 プロバイダに渡されたイベントを処理します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | Shutdown | オーバーライドされます。 プロバイダのシャットダウンに関連するタスクを実行します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- WmiWebEventProviderのページへのリンク