PDA

View Full Version : Pinging a Server - Need Help


evenmonkeys
09-17-2008, 06:31 PM
I am working with scratch here. I've been searching these forums all day and I can't seem to make any sense of what I'm finding. I'm going insane here.

I just want something very simple. I want to be able to display the status of my server on the forum somewhere, anywhere. I don't care. I can move things around rather easily. I'm just struggling creating it.

Anyways, what I want to do is ping my computer here and home to show whether or not it is connected to the internet. I run a private gaming server for my friends and I to play on, but it'd be nice if they knew whether or not it was up and running before they tried logging in. If the computer is turned on, the server is turned on.

Could someone either build me something or point me toward something SIMPLE. All I want to do is see if the thing's turned on. I am interested in placing the status in my header.

$ping = ping yarub's server;
$status = $ping;

Obviously that's not accurate, but you get my idea. Please help me. =(

SEOvB
09-17-2008, 06:36 PM
use a pinging script that will give you the output, then use the hooks and plugin system as instructed in the vBulletin manual and insert the code into your template

evenmonkeys
09-17-2008, 06:37 PM
That's the point. I can't find one that's simple enough for my mind to understand. =\

SEOvB
09-17-2008, 08:05 PM
Here's a easy one

http://www.greenbird.info/xantus-webdevelopment/ping

evenmonkeys
09-17-2008, 09:23 PM
That's the one I was trying. Could you possible help me make a plugin that would make it work? >_> 'Cause it's not working.

MoT3rror
09-18-2008, 02:34 AM
<a href="http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=8&txtCodeId=1786" target="_blank">http://www.planet-source-code.com/vb...txtCodeId=1786</a>

evenmonkeys
09-18-2008, 02:57 AM
So if it doesn't connect to the server, it prints out a million lines of error. That's not what I'm looking for. I want something simple. There's got to be an easier way to do this.

Server is Offline
Server if Online

That's all I want in the end.

EDIT: Maybe I'm asking for the wrong thing. I don't want to ping anything. I just want to see if the darn thing is connected to the internet. That's all I want.

Dismounted
09-18-2008, 05:25 AM
$site = 'yoursite.com';
$port = 80;
$check = @fsockopen($site, $port);

if (!$check)
{
echo 'Server is Currently Down!';
}
else
{
echo 'Server is Currently Up!';
}

gfxhelp.com
09-18-2008, 05:53 AM
Have a look at http://www.greycube.com/ and check out LGSL, not sure if it's what you're looking for, but it checks if game servers are up and can show stats for them too like players, maps, settings etc. It generally outputs a list of game servers which you specify by IP, but if you plan on making a small menu for just one game server you can easily redo the layout for a small menu.

MrEyes
09-18-2008, 07:43 AM
Does your local server run a web server of any description and if not is it possible to install one?

If yes, then there is a much easier solution....

Create a "server is online" image and put it on your local webserver, for example:

http://mylocalwebserver.dyndns.com/online.gif

Then create a "server is offline" image and put it on your internet/forum server, for example:

http://www.myinternetforum.com/offline.gif

Once you have the two images, you would then use javascript to attempt to load the "online.gif" image from your local server and if not possible it displays the "offline.gif" from the internet server.

Job done

EDIT: I did this for a project a few years ago, I will see if I can dig out the JS for it. No promises though

EDIT: Found it:

<html>
<head>
</head>

<body>
<img name="serverStatusImage" src="checking.gif" alt="Checking Server Status...">
<script type="text/javascript">
<!--
function SetOnlineStatus() {
document["serverStatusImage"].src = onlineImageSrc;
document["serverStatusImage"].alt = 'Server Online';
}

function SetOfflineStatus() {
document["serverStatusImage"].src = offlineImageSrc;
document["serverStatusImage"].alt = 'Server Offline';
}

var onlineImageSrc = 'http://www.google.co.uk/images/nav_logo3.png'
var offlineImageSrc = 'http://www.myinternetsite.com/offline.gif'

var onlineImage = new Image();
onlineImage.onload = SetOnlineStatus;
onlineImage.onerror = SetOfflineStatus;
onlineImage.src = onlineImageSrc;
//-->
</script>
</body>
</html>

The only thing I forgot is the "checking.gif" image which is displayed until the server check has been performed