用C#监视服务器信息

发表于:2007-06-30来源:作者:点击数: 标签:
script language=C# runat=server void Page_Load(Object sender, EventArgs ev) { ProcessInfo[] history = ProcessModelInfo.GetHistory(100); for( int i=0; ihistory.Length; i++ ) { Response.Write(TABLE BORDER); Response.Write(TR TD ); Response.Wr
<script language="C#" runat=server>

   void Page_Load(Object sender, EventArgs ev)
   {
      ProcessInfo[] history = ProcessModelInfo.GetHistory(100);

      for( int i=0; i<history.Length; i++ )
      {
         Response.Write("<TABLE BORDER>");
         Response.Write("<TR><TD>");
         Response.Write("StartTime<TD>"      + history[i].StartTime.ToString()       + "<BR>");
         Response.Write("<TR><TD>");
         Response.Write("Age<TD>"            + history[i].Age.ToString()             + "<BR>");
         Response.Write("<TR><TD>");
         Response.Write("ProcessID<TD>"      + history[i].ProcessID.ToString()       + "<BR>");
         Response.Write("<TR><TD>");
         Response.Write("RequestCount<TD>"   + history[i].RequestCount.ToString()    + "<BR>");
         Response.Write("<TR><TD>");
         Response.Write("Status<TD>"         + GetProcessStatus( history[i].Status ) + "<BR>");
         Response.Write("<TR><TD>");
         Response.Write("ShutdownReason<TD>" + GetShutdownReason( history[i].ShutdownReason) + "<BR>");
         Response.Write("<TR><TD>");
         Response.Write("PeakMemoryUsed<TD>" + history[i].PeakMemoryUsed.ToString()  + "<BR>");
         Response.Write("</TABLE><P><P>");
      }
   }

   public String GetProcessStatus( ProcessStatus ps )
   {
      String s = "Unknown";
      if( ps == ProcessStatus.Alive )
         s = "Alive";
      else if( ps == ProcessStatus.ShuttingDown )
         s = "Shutting Down";
      else if( ps == ProcessStatus.ShutDown )
         s = "Shutdown";
      else if( ps == ProcessStatus.Terminated )
         s = "Terminated";
      return s;
   }

   public String GetShutdownReason( ProcessShutdownReason psr )
   {
      String s = "Unknown";
      if( psr == ProcessShutdownReason.None )
         s = "N/A";
      else if( psr == ProcessShutdownReason.Unexpected )
         s = "Unexpected";
      else if( psr == ProcessShutdownReason.RequestsLimit )
             s = "Requests Limit";
      else if( psr == ProcessShutdownReason.RequestQueueLimit )
         s = "Request Queue Limit";
      else if( psr == ProcessShutdownReason.Timeout )
         s = "Timeout";
      else if( psr == ProcessShutdownReason.IdleTimeout )
         s = "Idle Timeout";
      else if( psr == ProcessShutdownReason.MemoryLimitExceeded )
         s = "Memory Limit Exceeded";
      return s;
   }
</script>

原文转自:http://www.ltesting.net