Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to find out if a server is up or down.

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
0
0
US
Hi. i have an intranet page that has several functions. one of them (planning on having) a page that checks a server to see if it's up or down. i've been trying several things to ping or read a text file on the server to see if it's up or down. but, i'm getting errors. is there any way to ping an ip address (server) in asp classic?
thanks.
 
Please can you post the code you have written so far?
 
From my library of "spider" routines
Code:
function GetPageResponse(strURL)
 Response.Buffer = True
  Dim objXMLHTTP, xml
  Set xml = Server.CreateObject("Microsoft.XMLHTTP")
  
 	xml.Open "HEAD", strURL, False
	xml.setRequestHeader "User-Agent", "UpTime BOT"
	xml.Send
	GetPageResponse = xml.getAllResponseHeaders()
  Set xml = Nothing
end function

If it returns a HTTP 200 response the server is "up"

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
thanks for posting a solution.
unfortunately it's giving an error on line 11 which is
xml.Open "HEAD", strURL, False
the error is: error '80004005'
i found another solution which also gave a different error:
Code:
 url = "[URL unfurl="true"]www.espn.com"[/URL] 
    WMI = "winmgmts:{impersonationLevel=impersonate}"  
    wqlQuery = "SELECT StatusCode FROM Win32_PingStatus WHERE Address" & _ 
        " = '" & url & "'"  
    set PingResult = GetObject(WMI).ExecQuery(wqlQuery, "WQL", 48)  
    Response.write url & " is " 
    For Each result in PingResult 
        if clng(result.StatusCode)>0 then 
            response.write "offline" 
        else 
            response.write "online" 
        end if 
    Next
the error on this was: error '80041003'
which was fixed by:
'-Open Computer Management
'-Expand Services and Applications
'-Select WMI Control
'-Right click WMI Control and select properties
'-Select Security tab
'-Select the namespace of choice (if you wish to apply to all select Root)
'-Click on the security button
'-Add the group of your choice
'-Click on the Advanced button
'-Select the group you added
'-Click on View/Edit
'-In the Apply onto field select "This namespace and subnamespaces"
'-Select the following rights:
'Execute Methods
'Provider Write
'Enable Account
'Remote Enable
'-Click on the OK button
'-Click on the OK button
'-Click on the OK button
'-Click on the OK button

best regards
 
Chris,

I'm interested in this issue so I tried your code.

I get:
msxml3.dll error '80070005'
Access is denied.

Google pointed me to:

where he says that due to some updates and security patches and stuff the script should be using:
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")

Tried that and I get:
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed

I'm guessing I just must not have access or permissions on my limited hosting arrangement and I won't be able to get it to go, but I don't know.

Thoughts?

Thought you might be interested in the msmxl3.dll thing in any event.

_______________________


<%
function GetPageResponse(strURL)
Response.Buffer = True
Dim objXMLHTTP, xml
'Set xml = Server.CreateObject("Microsoft.XMLHTTP")
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
xml.Open "HEAD", strURL, False
xml.setRequestHeader "User-Agent", "UpTime BOT"
xml.Send
GetPageResponse = xml.getAllResponseHeaders()
Set xml = Nothing
end function
%>

<p>Let's check espn.com.</p>
<p>response.write getPageResponse(" =
<%response.write getPageResponse("
 
Like I said, I have no doubt it runs for you and that on the free (limited) account I am on I won't be able to make it work.

I did notice that with the addition of an accidental space before the URL the code blows up. On your site I get:

"The page cannot be displayed because an internal server error has occurred."

I assume that is easily fixable with a trim().

Cheers.

 
Yep, easy fix that one.

All it needs now is the Round Tuit.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top