[advanced search]
13 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 12-19-2006, 11:11 AM   · #1
lee101
NamePros Regular
 
Name: Lee
Location: United Kingdom
Trader Rating: (8)
Join Date: Mar 2006
Posts: 339
NP$: 2.90 (Donate)
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
Server Status Script

Here is a simple server status script which I have made, it should work with most hosting accounts that have PHP enabled. If not you may need to change the servers in the services array, for example on shared hosting the HTTP server address may need to be changed to your websites URL.

A live demo is available here:
http://lee.conceptsublime.com/service_status.php

You can add/remove services by adding or removing them to/from the $services array.

Any feedback is appreciated!

To install just copy the code below into a php file, and run the php file. Advanced users may want to adjust the services it checks, depending on what you have installed on your server.
PHP Code:
<?php
/*
    Server Status Script
    Created by: Lee Findlow
    Contact:     leefindlow@gmail.com
    Website:     http://conceptsublime.com
*/
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Server Status Script</title>
</head>

<body>
<?php
//Page Variables
    
$online='<td style="background-color:#00FF00; padding:5px;">Online</td>';
    
$offline='<td style="background-color:#FF0000; padding:5px;">Offline</td>';
//Functions
    
function servercheck($server,$port){
        
//Check that the port value is not empty
        
if(empty($port)){
            
$port=80;
        }
        
//Check that the server value is not empty
        
if(empty($server)){
            
$server='localhost';
        }
        
//Connection
        
$fp=@fsockopen($server, $port, $errno, $errstr, 1);
            
//Check if connection is present
            
if($fp){
                
//Return Alive
                
return 1;
            } else{
                
//Return Dead
                
return 0;
            }
        
//Close Connection
        
fclose($fp);
    }
//Ports and Services to check
$services=array(
    
'HTTP (Port 80)' => array('localhost' => 80),
    
'HTTPS (Port 443)' => array('localhost' => 443),
    
'FTP (Port 21)' => array('localhost' => 21),
    
'MySQL (Port 3306)' => array('localhost' => 3306),
    
'SMTP (Port 25)' => array('localhost' =>  25),
    
'POP3 (Port 110)' => array('localhost' =>  110),
    
'Internet Connection' => array('google.com' => 80)
);
?>
<table>
<?php
//Check All Services
foreach($services as $name => $server){
?>
    <tr>
    <td><?php echo $name; ?></td>
<?php
    
foreach($server as $host => $port){
        if(
servercheck($host,$port)){ echo $online; }else{ echo $offline; }
    }
?>
    </tr>
<?php
}
?>
</table>
</body>
</html>


Thanks, Lee


Please register or log-in into NamePros to hide ads
__________________
http://bypasstopsite.com - Submit your proxy!
http://biggertwitter.com - Make twitter a bit bigger!
http://ubuntuserver.info - Ubuntu Server guides & more

Currently Developing - Linux Screenshots

Last edited by lee101 : 12-19-2006 at 11:15 AM.
lee101 is offline   Reply With Quote
Old 12-19-2006, 11:15 AM   · #2
Gene
DomainersUniversity.com
 
Gene's Avatar
 
Name: Gene
Location: Oswego, NY
Trader Rating: (93)
Join Date: Feb 2005
Posts: 4,366
NP$: 3483.60 (Donate)
Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute
Member of the Month
April 2005 Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease
Works great! Thank you Rep added
__________________
.
....◊ Learn how to profit with Domain Names at: DOMAINERS UNIVERSITY.
....WHOA! Gotta love this: PR0 to PR6 in 1 month! The "Blog Solution" is here.
....FREE download! 68 minute audio - How to Make $1,500 Today.
Gene is online now  
  Reply With Quote
Old 12-19-2006, 11:18 AM   · #3
Mikor
Resident Linux Geek
 
Mikor's Avatar
 
Name: Michael Walker
Location: East Yorkshire, England
Trader Rating: (7)
Join Date: Aug 2005
Posts: 2,413
NP$: 300.25 (Donate)
Mikor is a splendid one to beholdMikor is a splendid one to beholdMikor is a splendid one to beholdMikor is a splendid one to beholdMikor is a splendid one to beholdMikor is a splendid one to behold
Nice simple bit of code, that will help some people.
Rep++

Infact, its given me an idea for a program to make...
__________________
Me | Blog | Last.fm | F@h

archlinux User
Mikor is offline   Reply With Quote
Old 12-19-2006, 11:33 AM   · #4
lee101
NamePros Regular
 
Name: Lee
Location: United Kingdom
Trader Rating: (8)
Join Date: Mar 2006
Posts: 339
NP$: 2.90 (Donate)
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
Thanks everyone, seems like ti works then, it is actually a part of a larger project that I am working, although I thought i would release this as it is probably useful alone
__________________
http://bypasstopsite.com - Submit your proxy!
http://biggertwitter.com - Make twitter a bit bigger!
http://ubuntuserver.info - Ubuntu Server guides & more

Currently Developing - Linux Screenshots
lee101 is offline   Reply With Quote
Old 12-19-2006, 11:38 AM   · #5
Gene
DomainersUniversity.com
 
Gene's Avatar
 
Name: Gene
Location: Oswego, NY
Trader Rating: (93)
Join Date: Feb 2005
Posts: 4,366
NP$: 3483.60 (Donate)
Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute
Member of the Month
April 2005 Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease
Just a note: I 'think' it's working correctly, because the report I get says "Online" for all of the lines. But there is no way for me to know whether this report is correct. Just assuming it is!
__________________
.
....◊ Learn how to profit with Domain Names at: DOMAINERS UNIVERSITY.
....WHOA! Gotta love this: PR0 to PR6 in 1 month! The "Blog Solution" is here.
....FREE download! 68 minute audio - How to Make $1,500 Today.
Gene is online now  
  Reply With Quote
Old 12-19-2006, 11:43 AM   · #6
lee101
NamePros Regular
 
Name: Lee
Location: United Kingdom
Trader Rating: (8)
Join Date: Mar 2006
Posts: 339
NP$: 2.90 (Donate)
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
Oh, thanks for that Gene, I'll have a fiddle with it now to test it, On my PC I don't have HTTPS, SMTP or POP3 and it doesn't recognise any, but i'll fiddle around disabling stuff to make sure it recognises everything, hopefully it will though.
__________________
http://bypasstopsite.com - Submit your proxy!
http://biggertwitter.com - Make twitter a bit bigger!
http://ubuntuserver.info - Ubuntu Server guides & more

Currently Developing - Linux Screenshots
lee101 is offline   Reply With Quote
Old 12-19-2006, 12:57 PM   · #7
Noobie
DNOA Member
 
Noobie's Avatar
 
Name: Shoei
Location: Montreal, Quebec, Canada
Trader Rating: (0)
Join Date: Feb 2006
Posts: 324
NP$: 65.00 (Donate)
Noobie is on a distinguished road
Just a recommendation

PHP Code:
function servercheck($server,$port){
        
//Check that the port value is not empty
        
if(empty($port)){
            
$port=80;
        }
        
//Check that the server value is not empty
        
if(empty($server)){
            
$server='localhost';
        }


Can be
PHP Code:
function servercheck($server="localhost",$port="80")
__________________
Goldkey.com is a scam
What's your BMI? | Timestamp Generator
Noobie is offline   Reply With Quote
Old 01-16-2007, 12:15 PM   · #8
lee101
NamePros Regular
 
Name: Lee
Location: United Kingdom
Trader Rating: (8)
Join Date: Mar 2006
Posts: 339
NP$: 2.90 (Donate)
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
Updated Version

Hi,
Here's a slightly updated version of the script I posted before, I've made it more customisable so that you can format the output however you want.
PHP Code:
<?php
/*
    Server Status Script
    Created by: Lee Findlow
    Contact:     leefindlow@gmail.com
    Website:     http://conceptsublime.com
*/

//Standard Services to Check
    
$services=array(
        
'HTTP (Port 80)' => array('localhost' => 80),
        
'HTTPS (Port 443)' => array('localhost' => 443),
        
'FTP (Port 21)' => array('localhost' => 21),
        
'MySQL (Port 3306)' => array('localhost' => 3306),
        
'SMTP (Port 25)' => array('localhost' =>  25),
        
'POP3 (Port 110)' => array('localhost' =>  110),
        
'Internet Connection' => array('google.com' => 80)
    );

//Functions
    
function ServerCheck($server = 'localhost', $port = '80'){
        
//Connection
        
$fp=@fsockopen($server, $port, $errno, $errstr, 1);
            
//Check if connection is present
            
if($fp){
                
//Return Alive
                
return 1;
            } else{
                
//Return Dead
                
return 0;
            }
        
//Close Connection
        
fclose($fp);
    }

//Function to check all services in the $services array
    
function CheckAll(){
        
//Check All Services
        
global $services;
        foreach(
$services as $name => $server){
            foreach(
$server as $host => $port){
                
$status[$name] = ServerCheck($host,$port);
            }
        }
        return
$status;
    }
    
?>

This returns the services as an array, when you use the function CheckAll().
An example usage is
PHP Code:
<?php
include('file.php');
foreach(
CheckAll() as $service => $stat){
echo
$service.' - '.$stat.'<br />';
}

It returns 1/true if the service is online, and 0/false if it isn't

Thanks,
Lee
__________________
http://bypasstopsite.com - Submit your proxy!
http://biggertwitter.com - Make twitter a bit bigger!
http://ubuntuserver.info - Ubuntu Server guides & more

Currently Developing - Linux Screenshots
lee101 is offline   Reply With Quote
Old 01-16-2007, 02:13 PM   · #9
kleszcz
 
kleszcz's Avatar
 
Trader Rating: (229)
Join Date: Jul 2006
Posts: 3,257
NP$: 535.45 (Donate)
kleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond repute
Marrow Donor Program Multiple Sclerosis
Thanks Lee. Really helpful script for us. Rep added.
__________________
BQB.com auction: UJMH.com
LLLL.coms: ALL 2 Premium Letters + U + K
LLLL.com - *going cheap*
kleszcz is offline   Reply With Quote
Old 01-20-2007, 08:05 AM   · #10
DJ
Senior Member
 
DJ's Avatar
 
Location: .be
Trader Rating: (45)
Join Date: Dec 2004
Posts: 1,289
NP$: 152.12 (Donate)
DJ is a splendid one to beholdDJ is a splendid one to beholdDJ is a splendid one to beholdDJ is a splendid one to beholdDJ is a splendid one to beholdDJ is a splendid one to beholdDJ is a splendid one to beholdDJ is a splendid one to behold
Save a Life
Thanks Lee, i can use this one!
__________________
GETFireFox.NU | ImageUnload.com | SurfAnySite.com | UpLoads.cc | H.TL
NPEF.info - You can save someone's life
Online Portfolio | Names For Sale @ DOT.gd
DJ is offline  
  Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


Site Sponsors
http://www.internetinvestments.com/ http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 05:58 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0