?
Solved

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

Posted on 2010-04-04
14
Medium Priority
?
271 Views
Last Modified: 2013-12-12
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
0
Comment
Question by:966
  • 7
  • 6
14 Comments
 
LVL 8

Accepted Solution

by:
kumaranmca earned 2000 total points
ID: 29686651
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
 
LVL 18

Expert Comment

by:Andrej Pirman
ID: 29686768
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
 
LVL 8

Expert Comment

by:kumaranmca
ID: 29686902
you need server on/off status image..get it from the below url..

http://www.instantventrilo.com/ventrilo-server-status.php
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 

Author Comment

by:966
ID: 29689189
<?
 
$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
 
LVL 8

Expert Comment

by:kumaranmca
ID: 29691103
give you ip address of your site and port number


0
 

Author Comment

by:966
ID: 29691201
http://67.55.50.181  port 8440   to see if I get the red offline image
0
 
LVL 8

Expert Comment

by:kumaranmca
ID: 29691733
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
 

Author Comment

by:966
ID: 29691982
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
 
LVL 8

Expert Comment

by:kumaranmca
ID: 29692522
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
 

Author Comment

by:966
ID: 29692728
update, when i test the code in quick .php file it works fine.
just need to get it working inside my other page
0
 

Author Comment

by:966
ID: 29692772
got it, thanks,   i am stupid, my fault,  
0
 

Author Closing Comment

by:966
ID: 31710735
thanks man
0
 
LVL 8

Expert Comment

by:kumaranmca
ID: 29692990
Thank you, give the point...
0
 
LVL 8

Expert Comment

by:kumaranmca
ID: 29693087
sorry. given the points
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this article, we’ll look at how to deploy ProxySQL.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question