473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Checking server status via ASP.net

I swear I've read you can do this somewhere before, but don't recall where
or what it'd even be called to do the correct googling.

What I've been asked to do is make a 'dashboard' app that checks the status
of various servers. If they are down, show an error.

I found/modified this snippet:

---

Try
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("your url")
Dim res As Net.HttpWebResponse = req.GetResponse()
Dim str As IO.Stream = res.GetResponseStream()
Return New IO.StreamReader(str).ReadToEnd()
Catch ex As Exception
Return ex.Message
End Try
End Function

---

2 issues:

1) When I try to call the function ala:
<%=checkURL("http://google.com")%>

I get this error: "Invalid URI: The format of the URI could not be
determined."

Unfortunately, that appears to be a common SharePoint error, so Google
results are a bit cluttered.

2) Even if this does work, will it return anything if the server times out
(the main thing we're looking to check for?

-Darrel
Jun 27 '08 #1
7 2643
I hope you changed this line
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("your url")
"your url" suppose to be whatever you passing to checkURL

George.
"darrel" <no*****@nowhere.comwrote in message
news:eL**************@TK2MSFTNGP03.phx.gbl...
>I swear I've read you can do this somewhere before, but don't recall where
or what it'd even be called to do the correct googling.

What I've been asked to do is make a 'dashboard' app that checks the
status of various servers. If they are down, show an error.

I found/modified this snippet:

---

Try
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("your url")
Dim res As Net.HttpWebResponse = req.GetResponse()
Dim str As IO.Stream = res.GetResponseStream()
Return New IO.StreamReader(str).ReadToEnd()
Catch ex As Exception
Return ex.Message
End Try
End Function

---

2 issues:

1) When I try to call the function ala:
<%=checkURL("http://google.com")%>

I get this error: "Invalid URI: The format of the URI could not be
determined."

Unfortunately, that appears to be a common SharePoint error, so Google
results are a bit cluttered.

2) Even if this does work, will it return anything if the server times out
(the main thing we're looking to check for?

-Darrel

Jun 27 '08 #2
re:
!What I've been asked to do is make a 'dashboard' app that checks
!the status of various servers. If they are down, show an error.

I think you're basically looking for this :

http://weblogs.asp.net/scottgu/archi...14/433194.aspx

This solution doesn't use WebParts, but might give you a few ideas.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"darrel" <no*****@nowhere.comwrote in message news:eL**************@TK2MSFTNGP03.phx.gbl...
>I swear I've read you can do this somewhere before, but don't recall where or what it'd even be called to do the
correct googling.

What I've been asked to do is make a 'dashboard' app that checks the status of various servers. If they are down, show
an error.

I found/modified this snippet:

---

Try
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("your url")
Dim res As Net.HttpWebResponse = req.GetResponse()
Dim str As IO.Stream = res.GetResponseStream()
Return New IO.StreamReader(str).ReadToEnd()
Catch ex As Exception
Return ex.Message
End Try
End Function

---

2 issues:

1) When I try to call the function ala:
<%=checkURL("http://google.com")%>

I get this error: "Invalid URI: The format of the URI could not be determined."

Unfortunately, that appears to be a common SharePoint error, so Google results are a bit cluttered.

2) Even if this does work, will it return anything if the server times out (the main thing we're looking to check for?

-Darrel

Jun 27 '08 #3
>I hope you changed this line
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("your url")
"your url" suppose to be whatever you passing to checkURL
You have my permission to walk over here and smack me upside the head for
such a stupid mistake! ;o)

I am completely embarrassed by that one. ;o)

OK, so, that works! Now, to followup...

That returns the actual page. What I need to do is check for specific
errors. For instance, if it can't access the page at all, I get a "Unable to
connect to the remote server".

Is there a master list of these types of errors out there to reference
against?

Or, in general, is this even a good way to go about testing for the status
of a server?

-Darrel
Jun 27 '08 #4
the way I do it is to make custom page.
That connects to database, checks hard-drive space,.....
Basically does everything that needs to be checked. And outputs it as HTML.
Something like
Empty Space:1Gb<br>
Database: OK

Then your code simply displays it.

So you have for example
<%=checkURL("http://google.com/test.aspx")%>

And your checkURL will do folowing (pseducode, do not know VB well)

Function CheckUrl(sUrl) as String
Dim req As Net.HttpWebRequest
Dim res As Net.HttpWebResponse
Dim str As IO.Stream
Try
req = Net.WebRequest.Create("sUrl")
res = req.GetResponse()
str = res.GetResponseStream()
Return New IO.StreamReader(str).ReadToEnd()
Catch ex As WebException
ex.Response.Dispose()
Return "Connected to server but got an error: " & ex.Message
Catch e As Exception

Return "Could not connect to server: " & e.Message
Finally
if( str Not Is Nothing) Then str.Dispose()
if( res Not Is Nothing) Then res.Dispose()
End Try
End Function
PS: Do not forget to properly close Dispose objectes. You will run out of
resources soon otherwise.
But it only works if you can create your custom test.aspx page on the
server.
If not, you are limmited to was able to connect to server/was not able
to.....

George.
"darrel" <no*****@nowhere.comwrote in message
news:ue**************@TK2MSFTNGP04.phx.gbl...
I hope you changed this line
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("your url")
"your url" suppose to be whatever you passing to checkURL

You have my permission to walk over here and smack me upside the head for
such a stupid mistake! ;o)

I am completely embarrassed by that one. ;o)

OK, so, that works! Now, to followup...

That returns the actual page. What I need to do is check for specific
errors. For instance, if it can't access the page at all, I get a "Unable
to connect to the remote server".

Is there a master list of these types of errors out there to reference
against?

Or, in general, is this even a good way to go about testing for the status
of a server?

-Darrel

Jun 27 '08 #5
You've not said if they are all webservers, if not then an httprequest wont
help you much, and you'll need a tcp type ping request. The code is fairly
straightforward and you'll find httpget request example in the asp.net
quickstart.

Also, to run this kind of request in your sharepoint server, whther in a
webpart or not is almost certainly going to need a full trust level setting
in web.config.

Why don't you start by getting the code to work from a simple asp.net page,
and then migrate it into either a sharepoint page or a webpart if you can
get it to work.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"darrel" <no*****@nowhere.comwrote in message
news:eL**************@TK2MSFTNGP03.phx.gbl...
>I swear I've read you can do this somewhere before, but don't recall where
or what it'd even be called to do the correct googling.

What I've been asked to do is make a 'dashboard' app that checks the
status of various servers. If they are down, show an error.

I found/modified this snippet:

---

Try
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("your url")
Dim res As Net.HttpWebResponse = req.GetResponse()
Dim str As IO.Stream = res.GetResponseStream()
Return New IO.StreamReader(str).ReadToEnd()
Catch ex As Exception
Return ex.Message
End Try
End Function

---

2 issues:

1) When I try to call the function ala:
<%=checkURL("http://google.com")%>

I get this error: "Invalid URI: The format of the URI could not be
determined."

Unfortunately, that appears to be a common SharePoint error, so Google
results are a bit cluttered.

2) Even if this does work, will it return anything if the server times out
(the main thing we're looking to check for?

-Darrel

Jun 27 '08 #6
But it only works if you can create your custom test.aspx page on the
server.
If not, you are limmited to was able to connect to server/was not able
to.....
Good idea, though we really don't need anything that robust.

I found some suggestions one being to load the page, regex out the TITLE
tag, and compare it to what you think it should be. If it's different, then
either an error page loaded, or an error was returned.

The one unknown is what if the server just doesn't respond? I assume you'd
get some sort of time-out error. I'm just not quite sure how to test that
particular aspect yet. I'll have to wait for one of our servers to go down
;)

-Darrel
Jun 27 '08 #7
Also, to run this kind of request in your sharepoint server

I'm avoiding putting anything in SharePoint these days. ;0)

-Darrel
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marc S. Gibian | last post by:
I am putting together a Perl tool to manage a large set of tasks related to building a rather complex set of software. One of the goals for moving to Perl is to provide very rigorous error checking...
1
by: Rob Meade | last post by:
Hi all, Ok - minor problem - looking for work-a-rounds... I want to offer on our organisations intranet a support site for our webmasters, one of the features I'd like to add is a server...
5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
4
by: Phil Grimpo | last post by:
I had previously explained this problem in a different thread, but now that I have an IISState log, I figured I'd re-start the thred. My situation and the log are following... I have a very odd...
1
by: MSDN Account | last post by:
We have web site that used the IIS ResKit tool MSWC.PermissionChecker to check file permissions. The web site has been upgraded and that upgrade included changing the default server side language...
4
by: Emilio | last post by:
Hi, I have a form that contains various server validation controls, the submit button will either open a popup box or a popup window on the client-side click event. The question is, how do I...
3
by: Moe Sizlak | last post by:
Hi, Can I check a checkbox by default based on the value returned from a database? for example if the value (dr("frm7value")) returned from a db field is "YES" how can I check the checkbox by...
2
by: Maziar Aflatoun | last post by:
Hi everyone, I am reading and displaying data rows from my database where the first column contains the Status checkbox. I like to enable my users to change the status of individual rows by...
19
by: jeremyz | last post by:
Hi all, I am not a developer, but I work with several and am posting this for them. We are trying to determine whether it is possible to check the size of a file before a user uploads it. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.