WebProcessStatistics Classe
Definição
Fornece informações para avaliar a integridade de um processo em execução.Provides information for assessing the health of a running process.
public ref class WebProcessStatistics
public class WebProcessStatistics
type WebProcessStatistics = class
Public Class WebProcessStatistics
- Herança
-
WebProcessStatistics
Exemplos
O exemplo de código a seguir tem duas partes.The following code example has two parts. A primeira é um trecho do arquivo de configuração que permite que o ASP.NET use um evento personalizado que usa o WebProcessStatistics tipo.The first is an excerpt of the configuration file that enables ASP.NET to use a custom event that uses the WebProcessStatistics type. O segundo mostra como implementar esse evento personalizado.The second shows how to implement this custom event.
Certifique-se de que seu evento personalizado seja gerado no momento adequado, ou seja, quando o evento de integridade do sistema equivalente que ele substitui fosse gerado.Ensure that your custom event is raised at the proper time, that is, when the equivalent system health event it replaces would be raised.
<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
Comentários
O monitoramento de integridade do ASP.NET permite que a equipe de produção e operações Gerencie aplicativos Web implantados.ASP.NET health monitoring allows production and operations staff to manage deployed Web applications. O System.Web.Management namespace contém os tipos de eventos de integridade responsáveis pelo empacotamento de dados de status de integridade do aplicativo e os tipos de provedor responsáveis pelo processamento desses dados.The System.Web.Management namespace contains the health-event types responsible for packaging application health-status data and the provider types responsible for processing this data. Ele também contém tipos de suporte que ajudam durante o gerenciamento de eventos de integridade.It also contains supporting types that help during the management of health events.
As instâncias da WebProcessStatistics classe contêm informações que são obtidas usando o WebHeartbeatEvent tipo.Instances of the WebProcessStatistics class contain information that is obtained using the WebHeartbeatEvent type.
Observação
Na maioria dos casos, você poderá usar os tipos de monitoramento de integridade do ASP.NET conforme implementados e controlar o sistema de monitoramento de integridade especificando valores na healthMonitoring seção configuração.In most cases you will be able to use the ASP.NET health-monitoring types as implemented, and you will control the health-monitoring system by specifying values in the healthMonitoring configuration section. Você também pode derivar dos tipos de monitoramento de integridade para criar seus próprios provedores e eventos personalizados.You can also derive from the health-monitoring types to create your own custom events and providers. Para obter um exemplo de como criar uma classe de evento Personalizada, consulte o exemplo fornecido neste tópico.For an example of creating a custom event class, see the example provided in this topic.
Veja a seguir um trecho de um arquivo de configuração que você pode usar para habilitar o ASP.NET para registrar eventos de pulsação que contêm estatísticas de processo.The following is an excerpt of a configuration file you could use to enable ASP.NET to log heartbeat events that contain process statistics.
<healthMonitoring
enabled="true" heartBeatInterval="100">
<rules>
<add
name="Process Statistics"
eventName="Heartbeats"
provider="EventLogProvider"
profile="Default"/>
</rules>
</healthMonitoring>
Construtores
| WebProcessStatistics() |
Inicializa uma nova instância da classe WebProcessStatistics.Initializes a new instance of the WebProcessStatistics class. |
Propriedades
| AppDomainCount |
Obtém o número de domínios do aplicativo no processo.Gets the number of application domains in the process. |
| ManagedHeapSize |
Obtém o tamanho do heap gerenciado.Gets the size of the managed heap. |
| PeakWorkingSet |
Obtém o conjunto de trabalho de pico durante todo o tempo de vida do processo até o momento.Gets the peak working set for the lifetime of the process to date. |
| ProcessStartTime |
Obtém a hora de início do processo.Gets the time when the process started. |
| RequestsExecuting |
Obtém o número de solicitações em execução atualmente.Gets the number of requests currently executing. |
| RequestsQueued |
Obtém o número de solicitações esperando para serem processadas.Gets the number of requests waiting to be processed. |
| RequestsRejected |
Obtém o número de solicitações rejeitadas.Gets the number of rejected requests. |
| ThreadCount |
Obtém a contagem total de threads do processo.Gets the total count of the process threads. |
| WorkingSet |
Obtém o conjunto de trabalho do processo.Gets the working set for the process. |
Métodos
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| FormatToString(WebEventFormatter) |
Formata as estatísticas do processo.Formats the process statistics. |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |