Click here to Skip to main content
15,887,746 members
Articles / Web Development / ASP.NET

Detecting the UpTime of Web Server

Rate me:
Please Sign up or sign in to vote.
2.96/5 (18 votes)
19 Mar 2013CPOL2 min read 149.8K   1.3K   42   24
Sometimes it would be necessary to check how long our web server has been running or if our web server is being restarted too many times. Here we discuss a simple solution for the same.
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. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
Vasudevan Deepak Kumar is from Chennai, India who has been in the programming career since 1994, when he was 15 years old. He has his Bachelors of Engineering (in Computer Science and Engineering) from Vellore Engineering College. He also has a MBA in Systems from Alagappa University, Karaikudi, India.
He started his programming career with GWBasic and then in his college was involved in developing programs in Fortran, Cobol, C++. He has been developing in Microsoft technologies like ASP, SQLServer 2000.
His current focus is ASP.NET, C#, VB.NET, PHP, SQL Server and MySQL. In his past-time, he listens to polite Carnatic Music. But the big question is that with his current Todolist backlog, does he get some past time?

Comments and Discussions

 
GeneralMy vote of 5 Pin
Hüseyin Sekmenoğlu23-Feb-13 6:26
Hüseyin Sekmenoğlu23-Feb-13 6:26 
Generalany one have aspx file which can work with remote computer. Pin
Member 26678825-Jan-09 18:45
Member 26678825-Jan-09 18:45 
GeneralRe: any one have aspx file which can work with remote computer. Pin
mbaocha29-Apr-09 13:13
mbaocha29-Apr-09 13:13 
QuestionDid I get it wrong? Pin
RobMeade30-May-06 23:06
RobMeade30-May-06 23:06 
AnswerRe: Did I get it wrong? Pin
mbaocha9-May-09 19:19
mbaocha9-May-09 19:19 
QuestionHow to use my web application on another computer Pin
Nisarat30-Jun-05 18:25
Nisarat30-Jun-05 18:25 
GeneralUptime with WMI Pin
jserban23-May-05 4:46
jserban23-May-05 4:46 
QuestionMilliseconds instead of Seconds? Pin
SunB21-Apr-05 12:12
SunB21-Apr-05 12:12 
GeneralVery good Pin
FFSysCode12-Jan-05 19:06
FFSysCode12-Jan-05 19:06 
GeneralEasier way, without worrying about the "Access Denied" message. Pin
14-Jan-04 9:44
suss14-Jan-04 9:44 
GeneralRe: Easier way, without worrying about the "Access Denied" message. Pin
Matt Philmon11-Feb-04 7:56
Matt Philmon11-Feb-04 7:56 
GeneralRe: Easier way, without worrying about the "Access Denied" message. Pin
unRheal3-Jul-06 15:25
unRheal3-Jul-06 15:25 
Questionplease, what's your system setup? Pin
Anonymous12-Dec-02 16:26
Anonymous12-Dec-02 16:26 
QuestionCode does not work? Pin
smday110-Dec-02 10:37
smday110-Dec-02 10:37 
AnswerRe: Code does not work? Pin
Anonymous12-Dec-02 16:24
Anonymous12-Dec-02 16:24 
AnswerRe: Code does not work? Pin
evansc25-Dec-03 19:45
evansc25-Dec-03 19:45 
AnswerRe: Code does not work? Pin
Member 74183814-Jan-04 9:45
Member 74183814-Jan-04 9:45 
GeneralRe: Code does not work? Pin
VDragon26-Oct-06 10:49
VDragon26-Oct-06 10:49 
AnswerRe: Code does not work? Pin
Matt Philmon11-Feb-04 7:57
Matt Philmon11-Feb-04 7:57 
GeneralUptime.exe Pin
Anders Molin5-Dec-02 21:56
professionalAnders Molin5-Dec-02 21:56 
GeneralRe: Uptime.exe Pin
Vasudevan Deepak Kumar5-Dec-02 22:25
Vasudevan Deepak Kumar5-Dec-02 22:25 
GeneralRe: Uptime.exe Pin
Megan Forbes9-Dec-02 1:58
Megan Forbes9-Dec-02 1:58 
GeneralRe: Uptime.exe Pin
Anonymous24-Sep-03 14:07
Anonymous24-Sep-03 14:07 
GeneralRe: Uptime.exe Pin
unRheal3-Jul-06 15:35
unRheal3-Jul-06 15:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.