WebProcessStatistics Classe

Définition

Fournit des informations sur l'évaluation de l'état d'un processus en cours.

public ref class WebProcessStatistics
public class WebProcessStatistics
type WebProcessStatistics = class
Public Class WebProcessStatistics
Héritage
WebProcessStatistics

Exemples

L’exemple de code suivant comporte deux parties. Le premier est un extrait du fichier de configuration qui permet ASP.NET d’utiliser un événement personnalisé qui utilise le WebProcessStatistics type. La deuxième montre comment implémenter cet événement personnalisé.

Assurez-vous que votre événement personnalisé est déclenché au moment approprié, autrement dit, lorsque l’événement d’intégrité système équivalent qu’il remplace sera déclenché.

<healthMonitoring   
  enabled="true" heartBeatInterval="0">  

    <eventMappings>  
      <add  name="SampleProcessStatistics" type="SamplesAspNet.SampleWebProcessStatistics, webprocessstatistics, Version=1.0.1585.27289, Culture=neutral, PublicKeyToken=3648e5c763a8239f, processorArchitecture=MSIL"/>  
    </eventMappings>  

    <rules>  
      <add   
        name="Custom Process Statistics"  
        eventName="SampleProcessStatistics"   
        provider="EventLogProvider"    
        profile="Default"/>  
    </rules>  

</healthMonitoring>  

using System;
using System.Text;
using System.Web;
using System.Web.Management;

namespace SamplesAspNet
{
    // Implements a custom WebBaseEvent type that 
    // uses the WebProcessStatistics.
    public class SampleWebProcessStatistics :
      WebBaseEvent
    {
        private StringBuilder eventInfo;
        private static WebProcessStatistics processStatistics;

        // Instantiate the SampleWebProcessStatistics
        // type.
        public SampleWebProcessStatistics(string msg, 
            object eventSource, int eventCode):
          base(msg, eventSource, eventCode)
        {
            // Perform custom initialization.
            string customMsg = 
                string.Format("Event created at: {0}", 
                EventTime.ToString());

            eventInfo = new StringBuilder();
            eventInfo.AppendLine(customMsg);
            
            // Instantiate the WebProcessStatistics 
            // type.
            processStatistics = new WebProcessStatistics();
        }



        // Raises the event.
        public override void Raise()
        {
            // Perform custom processing. 
            eventInfo.Append(
                string.Format(
                "Event raised at: {0}\n", EventTime.ToString()));
            // Raise the event.
            base.Raise();
        }

        public string GetAppDomainCount()
        {
            // Get the app domain count.
            return (string.Format(
                "Application domain count: {0}",
                processStatistics.AppDomainCount.ToString()));
        }


        public string GetManagedHeapSize()
        {
            // Get the mamaged heap size.
            return (string.Format(
                "Managed heap size: {0}",
                processStatistics.ManagedHeapSize.ToString()));
        }


        public string GetPeakWorkingSet()
        {
            // Get the peak working set.
            return (string.Format(
                "Peak working set: {0}",
                processStatistics.PeakWorkingSet.ToString()));
        }


        public string GetProcessStartTime()
        {
            // Get the process start time.
            return (string.Format(
                "Process start time: {0}",
                processStatistics.ProcessStartTime.ToString()));
        }


        public string GetRequestsExecuting()
        {
            // Get the requests in execution.
            return (string.Format(
                "Requests executing: {0}",
                processStatistics.RequestsExecuting.ToString()));
        }


        public string GetRequestsQueued()
        {
            // Get the requests queued.
            return (string.Format(
                "Requests queued: {0}",
                processStatistics.RequestsQueued.ToString()));
        }


        public string GetRequestsRejected()
        {
            // Get the requests rejected.
            return (string.Format(
                "Requests rejected: {0}",
                processStatistics.RequestsRejected.ToString()));
        }


        public string GetThreadCount()
        {
            // Get the thread count.
            return (string.Format(
                "Thread count: {0}",
                processStatistics.ThreadCount.ToString()));
        }


        public string GetWorkingSet()
        {
            // Get the working set.
            return (string.Format(
                "Working set: {0}",
                processStatistics.WorkingSet.ToString()));
        }


        //Formats Web request event information.
        public override void FormatCustomEventDetails(
            WebEventFormatter formatter)
        {
            base.FormatCustomEventDetails(formatter);

            // Add custom data.

            formatter.AppendLine("");
            formatter.AppendLine(
                "Custom Process Statistics:");

            formatter.IndentationLevel += 1;

            // Get the process statistics.
            formatter.AppendLine(GetAppDomainCount());
            formatter.AppendLine(GetManagedHeapSize());
            formatter.AppendLine(GetPeakWorkingSet());
            formatter.AppendLine(GetProcessStartTime());
            formatter.AppendLine(GetRequestsExecuting());
            formatter.AppendLine(GetRequestsQueued());
            formatter.AppendLine(GetRequestsRejected());
            formatter.AppendLine(GetThreadCount());
            formatter.AppendLine(GetWorkingSet());

            formatter.IndentationLevel -= 1;

            formatter.AppendLine(eventInfo.ToString());
        }
    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management


' Implements a custom WebBaseEvent type that 
' uses the WebProcessStatistics.

Public Class SampleWebProcessStatistics
    Inherits WebBaseEvent
    Private eventInfo As StringBuilder
    Private Shared processStatistics As WebProcessStatistics

    ' Instantiate the SampleWebProcessStatistics
    ' type.
    Public Sub New(ByVal msg As String, ByVal eventSource As Object, ByVal eventCode As Integer) 
        MyBase.New(msg, eventSource, eventCode)
        ' Perform custom initialization.
        Dim customMsg As String = String.Format("Event created at: {0}", EventTime.ToString())
        
        eventInfo = New StringBuilder()
        eventInfo.AppendLine(customMsg)
        
        ' Instantiate the WebProcessStatistics 
        ' type.
        processStatistics = New WebProcessStatistics()
    
    End Sub
     


    ' Raises the event.
    Public Overrides Sub Raise()
        ' Perform custom processing. 
        eventInfo.Append(String.Format( _
        "Event raised at: {0}" + _
        ControlChars.Lf, EventTime.ToString()))
        ' Raise the event.
        MyBase.Raise()
    End Sub

    Public Function GetAppDomainCount() As String
        ' Get the app domain count.
        Return String.Format( _
        "Application domain count: {0}", _
        processStatistics.AppDomainCount.ToString())
    End Function 'GetAppDomainCount


    Public Function GetManagedHeapSize() As String
        ' Get the mamaged heap size.
        Return String.Format( _
        "Managed heap size: {0}", _
        processStatistics.ManagedHeapSize.ToString())
    End Function 'GetManagedHeapSize


    Public Function GetPeakWorkingSet() As String
        ' Get the peak working set.
        Return String.Format( _
        "Peak working set: {0}", _
        processStatistics.PeakWorkingSet.ToString())
    End Function 'GetPeakWorkingSet


    Public Function GetProcessStartTime() As String
        ' Get the process start time.
        Return String.Format( _
        "Process start time: {0}", _
        processStatistics.ProcessStartTime.ToString())
    End Function 'GetProcessStartTime


    Public Function GetRequestsExecuting() As String
        ' Get the requests in execution.
        Return String.Format( _
        "Requests executing: {0}", _
        processStatistics.RequestsExecuting.ToString())
    End Function 'GetRequestsExecuting



    Public Function GetRequestsQueued() As String
        ' Get the requests queued.
        Return String.Format( _
        "Requests queued: {0}", _
        processStatistics.RequestsQueued.ToString())
    End Function 'GetRequestsQueued


    Public Function GetRequestsRejected() As String
        ' Get the requests rejected.
        Return String.Format( _
        "Requests rejected: {0}", _
        processStatistics.RequestsRejected.ToString())
    End Function 'GetRequestsRejected


    Public Function GetThreadCount() As String
        ' Get the thread count.
        Return String.Format( _
        "Thread count: {0}", _
        processStatistics.ThreadCount.ToString())
    End Function 'GetThreadCount


    Public Function GetWorkingSet() As String
        ' Get the working set.
        Return String.Format( _
        "Working set: {0}", _
        processStatistics.WorkingSet.ToString())
    End Function 'GetWorkingSet



    'Formats Web request event information.
    Public Overrides Sub FormatCustomEventDetails( _
    ByVal formatter As WebEventFormatter)
        MyBase.FormatCustomEventDetails(formatter)

        ' Add custom data.
        formatter.AppendLine("")
        formatter.AppendLine("Custom Process Statistics:")

        formatter.IndentationLevel += 1

        ' Get the process statistics.
        formatter.AppendLine(GetAppDomainCount())
        formatter.AppendLine(GetManagedHeapSize())
        formatter.AppendLine(GetPeakWorkingSet())
        formatter.AppendLine(GetProcessStartTime())
        formatter.AppendLine(GetRequestsExecuting())
        formatter.AppendLine(GetRequestsQueued())
        formatter.AppendLine(GetRequestsRejected())
        formatter.AppendLine(GetThreadCount())
        formatter.AppendLine(GetWorkingSet())

        formatter.IndentationLevel -= 1

        formatter.AppendLine(eventInfo.ToString())
    End Sub
End Class

Remarques

ASP.NET surveillance de l’intégrité permet au personnel de production et d’exploitation de gérer les applications web déployées. L’espace System.Web.Management de noms contient les types d’événements d’intégrité responsables de l’empaquetage des données d’état d’intégrité de l’application et des types de fournisseurs responsables du traitement de ces données. Il contient également des types de prise en charge qui aident lors de la gestion des événements d’intégrité.

Les instances de la WebProcessStatistics classe contiennent des informations obtenues à l’aide du WebHeartbeatEvent type.

Notes

Dans la plupart des cas, vous pourrez utiliser les types de surveillance d’intégrité ASP.NET comme implémentés, et vous contrôlerez le système de surveillance de l’intégrité en spécifiant des valeurs dans la healthMonitoring section de configuration. Vous pouvez également dériver des types de surveillance de l’intégrité pour créer vos propres événements et fournisseurs personnalisés. Pour obtenir un exemple de création d’une classe d’événements personnalisée, consultez l’exemple fourni dans cette rubrique.

Voici un extrait d’un fichier de configuration que vous pouvez utiliser pour activer ASP.NET pour journaliser les événements de pulsation qui contiennent des statistiques de processus.

<healthMonitoring   
  enabled="true" heartBeatInterval="100">  

    <rules>  
      <add   
        name="Process Statistics"  
        eventName="Heartbeats"   
        provider="EventLogProvider"    
        profile="Default"/>  
    </rules>  

</healthMonitoring>  

Constructeurs

WebProcessStatistics()

Initialise une nouvelle instance de la classe WebProcessStatistics.

Propriétés

AppDomainCount

Obtient le nombre de domaines d'application dans le processus.

ManagedHeapSize

Obtient la taille du tas managé.

PeakWorkingSet

Obtient le nombre de jeux de travail maximal pour la durée de vie du processus en cours.

ProcessStartTime

Obtient l'heure à laquelle le processus a démarré.

RequestsExecuting

Obtient le nombre de demandes en cours d'exécution.

RequestsQueued

Obtient le nombre de demandes en attente de traitement.

RequestsRejected

Obtient le nombre de demandes rejetées.

ThreadCount

Obtient le nombre total de threads du processus.

WorkingSet

Obtient le jeu de travail pour le processus.

Méthodes

Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.

(Hérité de Object)
FormatToString(WebEventFormatter)

Met en forme les statistiques du processus.

GetHashCode()

Fait office de fonction de hachage par défaut.

(Hérité de Object)
GetType()

Obtient le Type de l'instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Object actuel.

(Hérité de Object)
ToString()

Retourne une chaîne qui représente l'objet actuel.

(Hérité de Object)

S’applique à

Voir aussi