Introduction
Occasionally, we would be in need to find how long our web server has been running and to find out whether the web server has been restarted or not, if it had experienced prolonged slowness for an extended period of time, say a couple of hours etc. In most of the hosting cases, we normally do not get a full console access to the web server and we might not be able to run the uptime.exe script that is normally available to check the uptime of a Windows system. Pinging the server might not be a valid choice because when the servers are behind NAT and firewalls, ICMP packets may either be blocked or might be responded to by the firewall.
The Solution
ASP.NET provides a sneak peek into system information through its Environment namespace and also Performance Counter. Here is a quick code tip as a humble endeavor to help people in deployment and maintenance of websites to have a comfortable control on their servers.
Requirements
All it needs for this quick utility is to have these two files 'default.aspx' (and/or its methods) in/as one of the webpages in your web application. There on when you visit the page, you would be given a quick option to check the uptime either through Performance Counter or Environment Tickcount. Though both are same, the latter was included as one of the options in the utility as guided by a peer member who suggested the same as a comment.
Use of PerfCounter was actually for demonstration purposes on the same through ASP.NET. However, ASP.NET may run into permissions issue when going through this method.
Summary
This utility, I hope would serve as quick tool as a sneak peek of the web server besides a learner's aide in using PerfCounters in ASP.NET.