Jump to content

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


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.

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.