다음을 통해 공유


WmiWebEventProvider 클래스

정의

ASP.NET 상태 모니터링 이벤트를 WMI(Windows Management Instrumentation) 이벤트에 매핑하는 이벤트 공급자를 구현합니다.

public ref class WmiWebEventProvider : System::Web::Management::WebEventProvider
public class WmiWebEventProvider : System.Web.Management.WebEventProvider
type WmiWebEventProvider = class
    inherit WebEventProvider
Public Class WmiWebEventProvider
Inherits WebEventProvider
상속
WmiWebEventProvider

예제

다음 예제에서는 WMI 이벤트 ASP.NET 상태 모니터링 웹 애플리케이션 상태 이벤트의 결과로 발급 한 소비자를 만드는 방법을 보여 줍니다.

참고

WmiWebEventProvider 클래스 및 모니터링 상태 이벤트 형식을 기본적으로 이미 구성 되어 있습니다. 하기만 하면 모든 상태 이벤트에 대 한 규칙을 정의 하는 것입니다. 상태 이벤트를 하지 디스패치되는 기억 합니다 WmiWebEventProvider 기본적으로 공급자입니다.


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;
                }
            }
        }
    }
}
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

    ' 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
End Class

다음 예제를 보여 주는 구성 파일의 일부는를 <healthMonitoring> ASP.NET을 사용할 수 있도록 하는 구성 섹션을 WmiWebEventProvider 모든 상태 모니터링 이벤트를 처리 하는 공급자입니다.

<healthMonitoring>  
  <rules>  
    <add   
      name="Using Wmi"  
      eventName="All Events"   
      provider="WmiWebEventProvider"   
      profile="Critical"/>  
  </rules>  
</healthMonitoring>  

설명

ASP.NET 상태 모니터링 프로덕션와 운영 스태프를 배포 된 웹 애플리케이션을 관리할 수 있습니다. System.Web.Management 네임 스페이스 애플리케이션 상태 데이터 및이 데이터 처리를 담당 하는 공급자 형식이 패키징 담당 상태 이벤트 형식을 포함 합니다. 또한 상태 이벤트를 관리 하는 동안 유용한 지 원하는 형식을 포함 합니다.

ASP.NET 상태 모니터링 이벤트 WMI 이벤트를 매핑할이 클래스를 사용 합니다. WMI 하위 시스템에 ASP.NET 상태 모니터링 이벤트에 전달할 수 있도록, 하려면 구성 해야 합니다 WmiWebEventProvider 에서 적절 한 설정을 추가 하 여 클래스를 <healthMonitoring> 구성 파일의 섹션입니다.

ASP.NET 상태 모니터링 이벤트 라우팅될 때 발생 하는 WMI 이벤트의 매개 변수를 설명 하는 Aspnet.mof 파일에 포함 된 정보는 WmiWebEventProvider 클래스 및 WMI 이벤트에 매핑됩니다. Aspnet.mof 파일은 .NET Framework 빌드 디렉터리에 저장됩니다(예: %windir%\Microsoft.NET\Framework\BuildNumber). 상태 모니터링 이벤트를 WMI 이벤트로 보고하는 방법에 대한 자세한 내용은 WMI를 사용하여 ASP.NET 상태 모니터링 이벤트 제공을 참조하세요.

참고

대부분의 경우에 구현 된 대로 ASP.NET 상태 모니터링 유형을 사용할 수 없게 됩니다 및에서 값을 지정 하 여 상태 모니터링 시스템을 제어 하는 <healthMonitoring> 구성 섹션입니다. 사용자 고유의 사용자 지정 이벤트 및 공급자 상태 모니터링 형식에서 파생할 수 있습니다. 사용자 지정 공급자를 만드는 예제를 보려면 방법: 상태 모니터링 사용자 지정 공급자 예제 구현합니다.

생성자

WmiWebEventProvider()

WmiWebEventProvider 클래스의 새 인스턴스를 초기화합니다.

속성

Description

관리 도구나 다른 UI(사용자 인터페이스)에 표시하기에 적합한 간단하고 이해하기 쉬운 설명을 가져옵니다.

(다음에서 상속됨 ProviderBase)
Name

구성 중 공급자를 참조하는 데 사용되는 이름을 가져옵니다.

(다음에서 상속됨 ProviderBase)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
Flush()

공급자의 버퍼에서 이벤트를 모두 제거합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
Initialize(String, NameValueCollection)

이 개체의 초기 값을 설정합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ProcessEvent(WebBaseEvent)

공급자에 전달된 이벤트를 처리합니다.

Shutdown()

공급자 종료와 관련된 작업을 수행합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보