how can I show "server status" on my site?

Hi, I would like to show members status of my server using a .gif image and text to show online when the server is online and offline when the server is offline.
Its a dedicated server.
red.gif and text next to it sayING Offline
green.gif and text next to it saying Online
966Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kumaranmcaCommented:
Hi,

Refer my code...also refer the below url...it might be helpful for you...

http://www.istanto.net/phpshow-onlineoffline-server-status.html


<?

$ip = "this.ismy.ip.number";
$port = "portnumber";

if ($check=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,(float)0.5))
{
fclose($check);
echo "MY OWN SERVER<br>";
echo "<img border='0' src='images/online.jpg' alt='ONLINE'>";
}
else
{
echo "MY OWN SERVER<br>";
echo "<img border='0' src='images/offline.jpg' alt='OFFLINE'>";
}

?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andrej PirmanCommented:
Try my code - it is one FUNCTION, and then PHP code inside HTML
<?php
function lookup_ports($hport,$hdomain) {
         $fp = @fsockopen($hdomain, $hport,$errno,$errstr,2) ;
         if (!$fp){
             $data = '<img alt="FAILURE: '.$hdomain.'" src="images/BAD.gif">';
         } else {
             $data = '<img alt="OK: '.$hdomain.'" src="images/GOOD.gif">';
             fclose($fp);
         }
         return $data;
		 ob_flush();
		flush();
}
?>

<?php 
// Enter your server's IP and port, which you are about to check
// You can check for SMTP port 25, POP3 110, HTTP 80 or any other open port

echo lookup_ports("80","11.22.33.44"); 
?>

Open in new window

0
kumaranmcaCommented:
you need server on/off status image..get it from the below url..

http://www.instantventrilo.com/ventrilo-server-status.php
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

966Author Commented:
<?
 
$ip = "this.ismy.ip.number";
$port = "portnumber";
 
if ($check=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,(float)0.5))
{
fclose($check);
echo "MY OWN SERVER<br>";
echo "<img border='0' src='images/online.jpg' alt='ONLINE'>";
}
else
{
echo "MY OWN SERVER<br>";
echo "<img border='0' src='images/offline.jpg' alt='OFFLINE'>";
}
 
?>


put this in, when I test it nothing shows?
ideas guys>?
0
kumaranmcaCommented:
give you ip address of your site and port number


0
966Author Commented:
http://67.55.50.181  port 8440   to see if I get the red offline image
0
kumaranmcaCommented:
Try this...i think your port number is wrong try.. below code....
<?php
 
$ip = "67.55.50.181";
$port = "21";
 
if ($check=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,(float)0.5))
{
fclose($check);
echo "MY OWN SERVER online<br>";
//echo "<img border='0' src='images/online.jpg' alt='ONLINE'>";
}
else
{
echo "MY OWN SERVER offline<br>";
//echo "<img border='0' src='images/offline.jpg' alt='OFFLINE'>";
}
 
?>

Open in new window

0
966Author Commented:
the port which my server will be in is 5555 so it should show red offline message>
even if wrong port should show offline?

btw code dont work, how can my code show green when on and red if port closed?
0
kumaranmcaCommented:
I have checked above code..i am getting server "ONLINE"

port number like::21 / 22

Also, try below....

<?php
 
$ip = "67.55.50.181";
$port = "21";
 
if ($check=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,(float)0.5))
{
fclose($check);
echo "MY OWN SERVER online<br>";
echo "<img border='0' src='images/online.jpg' alt='ONLINE'>";
}
else
{
echo "MY OWN SERVER offline<br>";
echo "<img border='0' src='images/offline.jpg' alt='OFFLINE'>";
}
 
?>

Open in new window

0
966Author Commented:
update, when i test the code in quick .php file it works fine.
just need to get it working inside my other page
0
966Author Commented:
got it, thanks,   i am stupid, my fault,  
0
966Author Commented:
thanks man
0
kumaranmcaCommented:
Thank you, give the point...
0
kumaranmcaCommented:
sorry. given the points
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.