Jump to content

Server Status Script


corbin

Recommended Posts

Well, I run a small site which checks the status (online/offline) of several servers (13) and the way i have it working is i have the [a href=\"http://l2status.no-ip.org\" target=\"_blank\"]main site[/a] include a page through an IFRAME which includes 4 other pages through IFRAMES. index.php has an IFRAME to status.php which opens IFRAME's to servers/1.php servers/2.php so on. And then in the servers/X.php pages it includes servers/config.php which is this:

[code]<?
error_reporting(0);
while(list($ServerName,$Host)=each($IP))
{
  list($IPAddress,$Port)=explode(":",$Host);
  if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5))
  {
   $server[$ServerName]="<font color=\"#00ff00\">Online</font>";
   fclose($fp);
  }else{
  if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5))
  {
  $server[$ServerName]="<font color=\"#00ff00\">Online</font>";
   fclose($fp);
  }
  else{
   $server[$ServerName]="<font color=\"#ff0000\">Offline</font>";
   }
  }
}
?>[/code]

and an example servers/X.php file is (i changed the IP addresses):

[code]
<body bgcolor="black"text="#FFFFFF">
<?
error_reporting(0);
$IP = array(
  "ia_login" =>"000.000.000.000:2106",
  "ia_aria"=>"000.000.000.000:7777",
  "ia_victoria" =>"000.000.000.000:7777",
);
fclose($fp);
include("config.php"); ?>
<b>
<div align="center" style="font-size: 12; font: bold;">
Login: <?  echo $server['ia_login']; ?><br>
Aria: <? echo $server['ia_aria']; ?><br>
Victoria <? echo $server['ia_victoria']; ?><br>
<div align="center">
<? fclose($fp); ?>
[/code]

So anyway... my question is... is there a more efficient way to go about doing the same thing?
Link to comment
Share on other sites

You can use fopen or similar functions to try to reach the various mirros.

If you don't get a response, most likely they are down.

[a href=\"http://www.php.net/fopen\" target=\"_blank\"]http://www.php.net/fopen[/a]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.