Jump to content

[SOLVED] Server Status Page | allow users to add servers to the list


winmastergames

Recommended Posts

Hi

Im trying to make a script that monitors servers if they are online or not how will i start off doing this. I thought you could have a form that asks the user for the Server Port and Name it then adds it to a MYSQL database then on the server status page it just checks the database for servers then checks they are online or not then displays them into a table

 

How will i do this or is there an easier way to do this

 

I have found this script on the internet how will i be able to edit it to suit my needs

status.html

<html>
<head>
<title>Web Server Status</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<table border="0" cellspacing="0" cellpadding="3">
  <tr> 
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">Microsoft.com</font></td>
    <td width="23%"><img src="status.php?link=www.microsoft.com" width="37" height="20"></td>
  </tr>
  <tr> 
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">Apple.com</font></td>
    <td width="23%"><img src="status.php?link=www.apple.com" width="37" height="20"></td>
  </tr>
  <tr> 
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">RedHat.com</font></td>
    <td width="23%"><img src="status.php?link=www.redhat.com" width="37" height="20"></td>
  </tr>
  <tr> 
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">Google.com</font></td>
    <td width="23%"><img src="status.php?link=www.google.com" width="37" height="20"></td>
  </tr>
</table>
</body>
</html>

 

And Status.php

<?php
//Web Server Status v 1.4, Copyright 2002 By Ryan Schwiebert, visit http://www.schwebdesigns.com/
//This script may be freely distributed providing all copyright headers are kept intact. 

//Concept from:
//Abax Server Status v1.04, Copyright 2002 By Nathan Dickman, visit http://www.NathanDickman.com/
//Location of the live or dead server images

//Please change to your server specifications
$live = "live2.gif";
$dead = "dead2.gif";

//The status checking script
//meddle at your own risk!
//check for port number, default is 80
$link = $_GET['link'].":";
$s_link = str_replace("::", ":", $link);
list($addr,$port)= explode (':',"$s_link");
if (empty($port)){
$port = 80;
}
//Test the server connection
$churl = @fsockopen(server($addr), $port, $errno, $errstr, 20);
             if (!$churl){
		 //echo $errstr;
                header("Location: $dead");
                }
             else {
             	  header("Location: $live");             
	  }
function server($addr){
         if(strstr($addr,"/")){$addr = substr($addr, 0, strpos($addr, "/"));}
         return $addr;
}
?>

If you want an automated process so you can get notifications or anyone could get notifications of it being down or up I would say most likely do a cron, otherwise if you just want it to be called when a user acesses part of your site just include the file as part of the page your user is acessing, may need to edit it a bit though.

Archived

This topic is now archived and is closed to further replies.

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