473,666 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.HttpWebRequ est = Net.WebRequest. Create("your url")
Dim res As Net.HttpWebResp onse = req.GetResponse ()
Dim str As IO.Stream = res.GetResponse Stream()
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("ht tp://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 2654
I hope you changed this line
Dim req As Net.HttpWebRequ est = Net.WebRequest. Create("your url")
"your url" suppose to be whatever you passing to checkURL

George.
"darrel" <no*****@nowher e.comwrote in message
news:eL******** ******@TK2MSFTN GP03.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.HttpWebRequ est = Net.WebRequest. Create("your url")
Dim res As Net.HttpWebResp onse = req.GetResponse ()
Dim str As IO.Stream = res.GetResponse Stream()
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("ht tp://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*****@nowher e.comwrote in message news:eL******** ******@TK2MSFTN GP03.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.HttpWebRequ est = Net.WebRequest. Create("your url")
Dim res As Net.HttpWebResp onse = req.GetResponse ()
Dim str As IO.Stream = res.GetResponse Stream()
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("ht tp://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.HttpWebRequ est = 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("ht tp://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.HttpWebRequ est
Dim res As Net.HttpWebResp onse
Dim str As IO.Stream
Try
req = Net.WebRequest. Create("sUrl")
res = req.GetResponse ()
str = res.GetResponse Stream()
Return New IO.StreamReader (str).ReadToEnd ()
Catch ex As WebException
ex.Response.Dis pose()
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*****@nowher e.comwrote in message
news:ue******** ******@TK2MSFTN GP04.phx.gbl...
I hope you changed this line
Dim req As Net.HttpWebRequ est = 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*****@nowher e.comwrote in message
news:eL******** ******@TK2MSFTN GP03.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.HttpWebRequ est = Net.WebRequest. Create("your url")
Dim res As Net.HttpWebResp onse = req.GetResponse ()
Dim str As IO.Stream = res.GetResponse Stream()
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("ht tp://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
4460
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 and handling. One area that has me puzzled is error checking some of the file system operations. Just simple things such as open, rename, unlink, print and some others ... all the sample code I've seen uses them in a form of: open(...) || die...
1
2288
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 status page. Currently webmasters use MS Frontpage to connect from their local PC to our development servers, work on their sites, then publish from there to our live servers.
5
3647
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 these menus are then placed into the page by calling Server.Execute(rs_Modules("ModulePath")). This works fine for up to 15 "menus" After that, the session variables that were set (not including those called by Global.ASA) are no longer set. ...
4
1967
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 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 these menus are then placed into the page by calling...
1
3326
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 from VBScript to C# (*.vbs --> *.cs). Does C# have a native method for doing what MSWC.PermissionChecker used to do? If so has anyone gone through converting the MSWC.PermissionChecker method to C# and would they share what they did? If not...
4
18671
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 check if the page is valid before it gets posted back to the server so the window or box only pops up if everything is OK? At the moment the popup occurs first then the validation. Many thanks
3
5222
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 default? Moe
2
6626
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 checking and unchecking the checkbox column. I like to update the status in the database for the column where the status was changed. This is what I'm doing so far
19
9265
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. Everything I've read suggests that this is impossible (or at least very difficult) in PHP, and this makes sense for a server-side language. What gives me pause, however, is the fact that when a user tries to upload a file larger than the max file...
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.