WmiWebEventProvider クラスとは? わかりやすく解説

WmiWebEventProvider クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

ASP.NET 状態監視イベントWMI (Windows Management Instrumentation) イベント割り当てるイベント プロバイダ実装ます。

名前空間: System.Web.Management
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Class WmiWebEventProvider
    Inherits WebEventProvider
Dim instance As WmiWebEventProvider
public class WmiWebEventProvider : WebEventProvider
public ref class WmiWebEventProvider : public
 WebEventProvider
public class WmiWebEventProvider extends WebEventProvider
public class WmiWebEventProvider extends
 WebEventProvider
解説解説

運用および操作担当者は、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.NETWmiWebEventProvider使用してすべての状態監視イベントを処理できます

<healthMonitoring>
</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.Object
   System.Configuration.Provider.ProviderBase
     System.Web.Management.WebEventProvider
      System.Web.Management.WmiWebEventProvider
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「WmiWebEventProvider クラス」の関連用語

WmiWebEventProvider クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WmiWebEventProvider クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS