Service Online Check Script

 
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions
View previous topic :: View next topic  
Author Message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Fri Apr 22, 2005 5:42 pm    Post subject: Service Online Check Script Reply with quote

Hi All,

Can someone design/recommend a few scripts that would tell me what services such as Perl, ASP, MySQL, CGI, POP and SMTP are online or not? I want to be able to tell the people who i host for which services are online and which are not etc, it will make life easier for them when trying out scripts etc.

Any help is appriciated. I am especially after MySQL, ASP and Perl scripts because I already have these working full time.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
mahel
-


Joined: 19 Apr 2005
Posts: 21
Location: Netherlands

PostPosted: Sat Apr 23, 2005 1:54 pm    Post subject: Reply with quote

I found one. You need to get your self an online and a offline image.
Name them: off.jpg and on.jpg

Code:
<?php
$domain = "localhost";
$dns_server="ns1.dnsjunction.com";
$sec_dns="ns1.dnsjunction.com";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Server Status</title>
</head>


<body>

<p><b><font size="5" face="Times New Roman, Times, serif">Server Status </font></b></p>

<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Online:<img src="on.jpg"><br>
Offline:<img src="off.jpg"><br><HR NOSHADE>

<?

function lookup_ports($hport,$hdomain) {
         $fp = fsockopen($hdomain, $hport,$errno,$errstr, 4);
         if (!$fp){
             $data = "<img src='off.jpg'>";
         } else {
             $data = "<img src='on.jpg'>";
             fclose($fp);
         }
         return $data;
}

   function get_server_software($domain) {
       $fp = fsockopen($domain, 80, $errno, $errstr, 1);

       if (!$fp) {
           return("");
       }

       else {
           fputs($fp, "HEAD / HTTP/1.1\r\nHost: " . $domain . "\r\n\r\n");

           while (!feof($fp)) {
               if (preg_match("/\bServer:/", $server = fgets($fp, 256))) {
                   fclose($fp);
                   return(substr($server, 8, -2));
               }
           }

           fclose($fp);
       }
   }


echo "<b>Checking services on: ".$domain;
echo "<br><br>Server type :";
echo get_server_software($domain);
echo "</b><br><br>";
echo "<br><li><b>HTTP:</b> <i>PORT 80 = <b>".lookup_ports("80",$domain)."</b></i></li>";
echo "<li><b>FTP:</b> <i>PORT 21 = <b>".lookup_ports("21",$domain)."</b></i></li>";
echo "<li><b>SMTP:</b> <i>PORT 25 = <b>".lookup_ports("25",$domain)."</b></i></li>";
echo "<li><b>POP:</b> <i>PORT 110 = <b>".lookup_ports("110",$domain)."</b></i></li>";
echo "<li><b>MySQL:</b> <i>PORT 3306 = <b>".lookup_ports("3306",$domain)."</b></i></li>";
echo "<li><b>IMAP:</b> <i>PORT 143 = <b>".lookup_ports("3306",$domain)."</b></i></li>";
echo "<li><b>DNS:[$dns_server]</b> <i>PORT 53 = <b>".lookup_ports("3306",$dns_server)."</b></i></li>";
echo "<li><b>Secondary DNS:[$sec_dns]</b> <i>PORT 53 = <b>".lookup_ports("3306",$sec_dns)."</b></i></li>";
echo "<li><b>DHCP:</b> <i>PORT 68 = <b>".lookup_ports("3306",$dns_server)."</b></i></li>";
echo "<li><b>SSL:</b> <i>PORT 443 = <b>".lookup_ports("3306",$domain)."</b></i></li>";
echo "<li><b>SSH:</b> <i>PORT 22 = <b>".lookup_ports("22",$domain)."</b></i></li>";
?>

</font>
</body>
</html>


This is not mine. I only found it
________
Herbal vaporizer


Last edited by mahel on Sun Feb 13, 2011 4:20 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sat Apr 23, 2005 3:19 pm    Post subject: Reply with quote

Thanks, it works for some of the services but not all of them. It would be ok to have seperate scripts too.

For Perl, for example, just say something along the lines of:

image 1=online.gif
image 2=offline.gif

if image 1=exists
display image 1
else if image 1=not exists
display image 2


I did this in JavaScript for HTTP and FTP but I cant do it for MySQL, Perl, ASP or CGI because I don't know these languages. Thats all I need.

Basically an alternative to:

Code:

<script type="text/javascript">
var Pic= new Array(10);

Pic[0] = new Image();
Pic[0].src = "images/offline.gif";

Pic[1] = new Image();
Pic[1].src = "http://www.m3ezw.co.uk/online.gif";
function wait() {
setTimeout("swappic1()", 2100);
}

function swappic1() {
if (Pic[1].complete)
   document.linetest1.src = Pic[1].src   
else
   document.linetest1.src = Pic[0].src; 
}

</script>

<img src="images/wait.gif" name="linetest1" alt="Status Unavailable" align="middle">


which was my original JavaScript one. I basically want the JavaScript one converted to MySQL, Perl, ASP, CGI and a simple script in any language (preferably PHP) for the FTP Status.

When I have all these scripts and the languages running i can modify them to suit my needs. I just want them so everyone who i host for on my system knows whether the services are online or not before blaming their script :P

Thanks for everyones help so far.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Tim1681
-


Joined: 17 Jan 2005
Posts: 160
Location: Bristol, CT, USA

PostPosted: Sat Apr 23, 2005 3:44 pm    Post subject: Reply with quote

I used this one & it works nicely for me. Heres the one from my server:

PHP
Code:
<?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 = "http://24.2.181.37/status/live2.gif";
$dead = "http://24.2.181.37/status/dead2.gif";

$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, 1);
             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;
}
?>



HTML Page:
Code:
<html>
<head>
<title>ZGServ Web Status</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="style2.css">
</head>
<body bgcolor="#000000">
<table border="0" cellspacing="0" cellpadding="3" align="center">
   <tr align="center">
      <td colspan="2"><u>ZGServ Web Status Page</u><br><br></td>
   </tr>
  <tr>
    <td width="77%">ZGServ</td>
    <td width="23%"><img src="status.php?link=xx.xx.xx.xx" width="37" height="20"></td>
  </tr>
  <tr>
    <td width="77%">ZGServ - FTP</td>
    <td width="23%"><img src="status.php?link=xx.xx.xx.xx:21" width="37" height="20"></td>
  </tr>
  <tr>
    <td width="77%">ZGServ - Ventrilo</td>
    <td width="23%"><img src="status.php?link=xx.xx.xx.xx:3784" width="37" height="20"></td>
  </tr>
  <tr align="center">
     <td colspan="2"><br><Br>Online - <img src="http://xx.xx.xx.xx/status/live2.gif"> Offline - <img src="http://xx.xx.xx.xx/status/dead2.gif"></td>
  </tr>
</table><br><Br>
<center>Copyright &copy 2005 Zerogroundz Ind. All Rights Reserved
</body>
</html>
Back to top View user's profile Send private message AIM Address
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Apr 24, 2005 2:32 pm    Post subject: Reply with quote

Thanks for that, but I figured out how i would do this script, i just need to know how to echo items in Perl, CGI, ASP etc to do it.

Can someone give me a simple script for each to show how to echo it? I will be using javascript so i need to know how to do that.

Thanks for all your help. I will keep that script for future use :P
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group