Link to home
Start Free TrialLog in
Avatar of derick_loo
derick_loo

asked on

PLEASE ! check web server status

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.
Avatar of sajuks
sajuks

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
%>
ASKER CERTIFIED SOLUTION
Avatar of sajuks
sajuks

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
again
====
Dim oHTTP = Server.CreateObject("WinHTTP.WinHTTPRequest")
oHTTP.Open "GET","http://SecondServer/",False
oHTTP.Send

If oHTTP.Status = "200" Then
  'OK
End If
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

%>
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.
>   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);
}
just to make it better, I would extend it to support  -->  Msxml2.XMLHTTP.4.0
Avatar of derick_loo

ASKER

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.
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.
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

> it is specific to MSIE...

it works with IE and Mozilla and others, this does the trick -->  xmlhttp=new XMLHttpRequest(); <-- this is not IE
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
...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
davidlars99, the code u post not work.  is i save the code in .asp ok?
derick_loo, that code is javascript... however I'm glad you accepted your answer wizely  :)
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.....
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