`
leonardleonard
  • 浏览: 777062 次
社区版块
存档分类
最新评论

ASP.NET 的性能监控

阅读更多

MSDN原文 ASP.NET Performance Monitoring, and When to Alert Administrators 下载源代码

Monitoring Performance Counters
Monitoring the Event Log
Monitoring the W3C and HTTPERR Logs
Other Resources Used to Monitor ASP.NET
Understanding the Performance Counters
   .NET CLR Exceptions Counter
   .NET CLR Loading Counters
   .NET CLR Memory Counters
   ASP.NET Counters
   ASP.NET Applications Counters
   Process Counters
   Processor Counter
   Memory Counter
   System Counter
   Web Service Counters
Conclusion

主要讨论的是如何使用ASP.NET的性能计数器。主要包括以下几个方面

  • Processor(_Total)\% Processor Time
  • Process(aspnet_wp)\% Processor Time
  • Process(aspnet_wp)\Private Bytes
  • Process(aspnet_wp)\Virtual Bytes
  • Process(aspnet_wp)\Handle Count
  • Microsoft® .NET CLR Exceptions\# Exceps thrown / sec
  • ASP.NET\Application Restarts
  • ASP.NET\Requests Rejected
  • ASP.NET\Worker Process Restarts (not applicable to IIS 6.0)
  • Memory\Available Mbytes
  • Web Service\Current Connections
  • Web Service\ISAPI Extension Requests/sec

如何在Application_Error事件中监视出错信息。

void Application_Error(Object sender, EventArgs ea) {
    StringBuilder message = new StringBuilder();
   
    if (Request != null) {
        message.AppendFormat(uriFormat, Request.Path);
    }
 
    if (Server != null) {
        Exception e;
        for (e = Server.GetLastError(); e != null; e = e.InnerException) {
            message.AppendFormat(exceptionFormat,
                                 e.GetType().Name,
                                 e.Message,
                                 e.StackTrace);
        }
    }

    if (!EventLog.SourceExists(sourceName)) {
        EventLog.CreateEventSource(sourceName, logName);
    }

    EventLog Log = new EventLog(logName, serverName, sourceName);
    Log.WriteEntry(message.ToString(), EventLogEntryType.Error);

    //Server.ClearError(); // uncomment this to cancel the error
}


.NET CLR Exceptions Counter  当运行Response.Redirect() Server.Transfer() Response.End() 会抛出ThreadAbortException错误,如果不想抛出错误,Response.Redirect(url,false)。

Application Restarts 以下为可能引发Application Restart 的情况

  • Modification of machine.config, web.config, or global.asax.
  • Modification of the application's bin directory or its contents.
  • When the number of compilations (ASPX, ASCX, or ASAX) exceeds the limit specified by <compilation numRecompilesBeforeAppRestart=/>.
  • Modification of the physical path of a virtual directory.
  • Modification of the code-access security policy.
  • The Web service is restarted.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics