Click to See Complete Forum and Search --> : server down


tanfwc
09-12-2003, 12:54 PM
how do i do this...

client visit server A->server A redirect to server B->but server B is down->client been redirected back to server A...

Khalid Ali
09-12-2003, 01:05 PM
you will have to make sure before redirection that server B is online,once you send an HTTP request,its out of your control until it gets to the other side.

Have some utility on server A to ping the server B

pyro
09-12-2003, 01:23 PM
You would be better off with a PHP or Perl script to ping the server, but you could something like this bit of JavaScript:

<script type="text/javascript">

var img = new Image();
img.src = 'http://www.yourdomain.com/images/spacer.png';
img.onload = function () {document.getElementById("online").style.backgroundColor="#00ff00";}
img.onerror = function () {document.getElementById("online").style.backgroundColor="red";}

</script>

Server Status: <span id="online" style="width: 10px; height: 10px; background-color: transparent; font-size: 1px;"></span>Which will check the status of an image (be sure the image exists on the server!) and if it is able to load it, it will know that the server is online.

tanfwc
09-13-2003, 08:00 AM
how can i replace the colour with picture?

tanfwc
10-27-2003, 09:39 AM
bump

pyro
10-27-2003, 11:50 AM
<script type="text/javascript">

var img = new Image();
img.src = 'http://www.yourdomain.com/images/spacer.png';
img.onload = function () {document.onlineimg.src = "online.gif";}
img.onerror = function () {document.onlineimg.src = "offline.gif";}

</script>

Server Status: <img src="offline.gif" name="onlineimg">

tanfwc
10-27-2003, 01:01 PM
thank you.

tanfwc
10-27-2003, 01:14 PM
let say i wan to monitor ten web site...then how sld the code be??

tanfwc
10-27-2003, 03:05 PM
Originally posted by pyro
<script type="text/javascript">

var img = new Image();
img.src = 'http://www.yourdomain.com/images/spacer.png';
img.onload = function () {document.onlineimg.src = "online.gif";}
img.onerror = function () {document.onlineimg.src = "offline.gif";}

</script>

Server Status: <img src="offline.gif" name="onlineimg">

how to delay check from coming up in around 3 seconds?

pyro
10-27-2003, 03:29 PM
Add it in a function and use setTimeout (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1203758) to force it to wait.

tanfwc
10-27-2003, 03:31 PM
Originally posted by tanfwc
let say i wan to monitor ten web site...then how sld the code be??

how about this?

pyro
10-27-2003, 03:41 PM
Try setInterval() (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1203669) instead.

tanfwc
10-27-2003, 03:46 PM
Originally posted by pyro
Add it in a function and use setTimeout (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1203758) to force it to wait.

how do i add in the function ? i am a total idiot in javascript...

pyro
10-27-2003, 03:57 PM
<script type="text/javascript">

function checkServer() {
var img = new Image();
img.src = 'http://www.yourdomain.com/images/spacer.png';
img.onload = function () {document.onlineimg.src = "online.gif";}
img.onerror = function () {document.onlineimg.src = "offline.gif";}
}
setInterval("checkServer()", 60*1000); //set for one minute
</script>
</head>
<body>
<p>Server Status: <img src="offline.gif" name="onlineimg"></p>

tanfwc
10-27-2003, 04:53 PM
Originally posted by pyro
<script type="text/javascript">

function checkServer() {
var img = new Image();
img.src = 'http://www.yourdomain.com/images/spacer.png';
img.onload = function () {document.onlineimg.src = "online.gif";}
img.onerror = function () {document.onlineimg.src = "offline.gif";}
}
setInterval("checkServer()", 60*1000); //set for one minute
</script>
</head>
<body>
<p>Server Status: <img src="offline.gif" name="onlineimg"></p>

thank you

pyro
10-27-2003, 06:20 PM
You are welcome... :)

serik16
05-28-2007, 01:47 PM
can you please please help me with some scripting like this...
I`m quite new to Javascript and can`t manage to sort this out...
I want to check if an server is online (port is 27015 !) .... if it is online I want the page to contain "Server Status : ONLINE!" , if not it should be "Server Status : OFFLINE!" ...
can you PLEASE PLEASE help me out with this!? :(

ps : i want to check if the client can connect to the server using some sort of "ping " ...
here`s an example :
the ip is 127.2.3.4:27015 (with port) and if the user can connect to that then "Online!" should be shown ... if not "offline" ... can this be made ? :((