[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PLEASE ! check web server status

Posted on 2005-05-07
18
Medium Priority
?
386 Views
Last Modified: 2008-02-01
I have a 2 web server.  I already design a web page and publish it out.  I need to coding a function to let user know  whether my web server is online or offline.  I design my web page using ASP code and save as .asp
Any 1 can help me.
0
Comment
Question by:derick_loo
  • 6
  • 5
  • 3
  • +2
18 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 13950150
You could download ASPping from http://www.serverobjects.com/products.htm
http://www.serverobjects.com/comp/aspping.zip
<%
  rem ***********************************************************
  rem * Create the object
  rem ***********************************************************
  Set Pinger = Server.CreateObject("AspPing.Conn")
  rem ***********************************************************
  rem * Set the host we'll be pinging
  rem ***********************************************************
  Pinger.RemoteHost = "www.microsoft.com"
  rem ***********************************************************
  rem * Optional count for number of times to ping remotehost
  rem * defaults to 1
  rem ***********************************************************
  Pinger.PingCount = 2
  rem ***********************************************************
  rem * Ping and then dump the results
  rem ***********************************************************
  Response.Write "<pre>" & Pinger.Ping & "</pre>"
  rem ***********************************************************
  rem * Release the object
  rem ***********************************************************
  Set Pinger = nothing
%>
0
 
LVL 33

Accepted Solution

by:
sajuks earned 375 total points
ID: 13950159
or use XMLHTTP(http://www.devguru.com/features/tutorials/XmlHttp/XmlHttp1.html)
<%
' code sample by mgfranz
 ' Intruduce the url you want to visit
 GotoURL = "http://www.xyz.com/testpage.asp" 
 ' Create the xml object
 Set GetConnection = CreateObject("Microsoft.XMLHTTP")
 ' Conect to specified URL
 GetConnection.Open "get", GotoURL, False
 On Error Resume Next
 GetConnection.Send  

 ' ResponsePage is the response we will get when visiting GotoURL
 ResponsePage = GetConnection.ResponseText

' We will write  
If ResponsePage="" then  
    Response.Redirect "http://www.abd.com/other.asp
Else
    Response.Redirect "http://www.xyz.com/open.asp"
End if

 Set GetConnection = Nothing
 %>
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13950409
too convoluted


Dim oHTTP = Server.CreateObject("WinHTTP.WinHTTPRequest")
oHTTP.
oHTTP.Open "GET","http://SecondServer/",False
oHTTP.Send

If oHTTP.Status = "200" Then
  'OK
End If
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 23

Expert Comment

by:b1xml2
ID: 13950410
again
====
Dim oHTTP = Server.CreateObject("WinHTTP.WinHTTPRequest")
oHTTP.Open "GET","http://SecondServer/",False
oHTTP.Send

If oHTTP.Status = "200" Then
  'OK
End If
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13950423
the progid should be as follows:

<%@Language="VBScript"%>
<%
Dim oRequest
Set oRequest = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "GET", "http://www.yahoo.com/",False
oRequest.Send

If oRequest.Status = "200" Then

      Response.Write "OK"
End If

%>
0
 
LVL 6

Expert Comment

by:cjinsocal581
ID: 13951156
If the webserver is offline, how do you plan to host these status pages? On the other server? And what if it is offline?

Just some random thoughts.
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 13951629
>   If the webserver is offline, how do you plan to host these status pages? On the other server? And what if it is offline?...

cjinsocal581, the answer is Javascript from any PC

<script type="text/javascript" language="JavaScript">

var xmlhttp;

function check(){

      var url="http://www.yahoo.com";

      try{
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
      }catch(e){
            try{
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){
                  try{
                        xmlhttp=new XMLHttpRequest();
                  }catch(e){
                        xmlhttp=null;
                  }
            }
      }
      try{
            xmlhttp.open("GET",url,true);
            xmlhttp.onreadystatechange=Loaded;
            xmlhttp.send(null);
      }catch(e){
            alert(e.message);
      }
}

function Loaded(){
      alert(xmlhttp.responseText);
}
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 13951633
just to make it better, I would extend it to support  -->  Msxml2.XMLHTTP.4.0
0
 

Author Comment

by:derick_loo
ID: 13952974
my web page is host at third server, i need to display the the user whether the other 2 server whether is online or offline
when user browse my web page, they can know whether the other 2 server is online or offline. the web page will display the word "offline" when the web server is  offline. if online will show  "online" on the web page.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13953241
The XMLHTTP object piggy backs off wininet.dll and is not suited for ASP applications.

Microsoft recommends the use of Msxml2.ServerXMLHTTP which actually implements the WinHttp.WinHttpRequest.5.1 (WINHTTP.DLL) a new implementation that provides better functionality for ASP applications.

Do not use XMLHTTP on the server side.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13953244
the code by davidlars99 is perfectly legitimate, however on the client-side. But the drawback of using that client-side code is that it is specific to MSIE

0
 
LVL 13

Expert Comment

by:davidlars99
ID: 13953583
> it is specific to MSIE...

it works with IE and Mozilla and others, this does the trick -->  xmlhttp=new XMLHttpRequest(); <-- this is not IE
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13953603
I stand corrected [does not occur too many times =) ] by davidalars99. The code would work in Mozilla but will not work with lower and older browsers.

In my opinion, if you can get a cross browser Mozilla-MSIE client-side script that works for newer browser, it is okay in my books. There's just too little in usage with other browsers to worry about unless you have the budget for this sort of thing
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 13954073
...and of course there's always a tricky way to walk around the problem...  :)

check this out, it works for *ALL* browsers as long as they support frames and javascript

http://www.frozendev.com/temp/network_raw.js
0
 

Author Comment

by:derick_loo
ID: 13956641
davidlars99, the code u post not work.  is i save the code in .asp ok?
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 13957014
derick_loo, that code is javascript... however I'm glad you accepted your answer wizely  :)
0
 

Author Comment

by:derick_loo
ID: 13984494
halo sajuks, the code u give me whether need install Microsoft office in the machine? if I use windows 2000 server without microsoft office, is the code function?
Please.....
0
 
LVL 33

Expert Comment

by:sajuks
ID: 13993617
Microsoft office shouldnt be a criteria but Microsoft.XMLHTTP should be there which would already be there
if your browser has the latest updates and patches
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question