Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb Server Monitoring via asp.net web page
    text
    copied!<p>I would like to monitor the following on a web page:</p> <ul> <li>Total response time</li> <li>Total bytes</li> <li>Throughput (requests/sec)</li> <li>RAM used</li> <li>Hard drive space and IO issues</li> <li>Server CPU overhead</li> <li>Errors (by error code)</li> <li>MSSQL load</li> <li>IIS errors</li> </ul> <p>I host a small cluster of servers for web hosting. I need to create a hardware view within ASP.NET to get as close to a real-time snapshot as possible of what's going on.</p> <p>I have heard of Spiceworks or other means for accomplishing this task. I agree that these are great tools, but I would like to code this and just keep it simple.</p> <p>Here is some existing code I have come up with/found:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string[] logicalDrives = System.Environment.GetLogicalDrives(); //do stuff to put it in the view. } protected static string ToSizeString(double bytes) { var culture = CultureInfo.CurrentUICulture; const string format = "#,0.0"; if (bytes &lt; 1024) return bytes.ToString("#,0", culture); bytes /= 1024; if (bytes &lt; 1024) return bytes.ToString(format, culture) + " KB"; bytes /= 1024; if (bytes &lt; 1024) return bytes.ToString(format, culture) + " MB"; bytes /= 1024; if (bytes &lt; 1024) return bytes.ToString(format, culture) + " GB"; bytes /= 1024; return bytes.ToString(format, culture) + " TB"; } public static string ToApproximateString(this TimeSpan time) { if (time.TotalDays &gt; 14) return ((int)(time.TotalDays / 7)).ToString("#,0.0") + " weeks"; if (14 - time.TotalDays &lt; .75) return "two weeks"; if (time.TotalDays &gt; 1) return time.TotalDays.ToString("#,0.0") + " days"; else if (time.TotalHours &gt; 1) return time.TotalHours.ToString("#,0.0") + " hours"; else if (time.TotalMinutes &gt; 1) return time.TotalMinutes.ToString("#,0.0") + " minutes"; else return time.TotalSeconds.ToString("#,0.0") + " seconds"; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload