Page 1 of 1

PHP script to know server status

Posted: Sat Jul 11, 2009 3:25 pm
by matteppi
Hi.. i'm making some Php scripts that i'll share with the community..
Now i'm trying to make a script that will show, the status of th server..
but i don't know how to know if the server is Up or not..
Maybe with the telnet server?
I was thinking this:
makeing a php telnet connection to the server..
if it can connect.. the server is ON, otherwise it is OFF...
What do you think??

Re: PHP script to know server status

Posted: Sat Jul 11, 2009 4:19 pm
by janiii
search for other php scripts. there are enough out there :)

Re: PHP script to know server status

Posted: Sat Jul 11, 2009 5:26 pm
by momo61
i kinda need a server status script :o

Re: PHP script to know server status

Posted: Sat Jul 11, 2009 7:54 pm
by lantoc

Code: Select all

if ( @fsockopen ($IP, 7777, $errno, $errstr, 1) )

Re: PHP script to know server status

Posted: Sun Jul 12, 2009 9:14 am
by matteppi
Thx... you've benn very useful.. once i'll terimante my scripts, i will host them.. and share with the forum..

Re: PHP script to know server status

Posted: Sun Jul 12, 2009 11:04 am
by Vapulabe
If you want more options, have a look at the Facebook developper API... it uses several methods to send the network request to Facebook, including (but not only) fsockopen.

You may want to check both the login server and the game server (if login server is down, mark all servers down). You may also try to connect to either the game port or the telnet port (either using only a connection or login in and getting extra info)

Re: PHP script to know server status

Posted: Sun Jul 12, 2009 4:17 pm
by matteppi
Ok, i made the script, but my Webhosting service.. deny fsockopen() function, so i can't test it...

Re: PHP script to know server status

Posted: Sun Jul 12, 2009 7:18 pm
by Vapulabe
That's why I told you to have a look at Facebok API... If I remind well, they use 3 or 4 methods using different interfaces (Curl, fsock, ...) to make the requests to FB

Re: PHP script to know server status

Posted: Fri Jul 17, 2009 3:25 pm
by neo25
Here is the one I use if anyone wants it. Just edit the IP address in status.php
Server Status.rar

Re: PHP script to know server status

Posted: Tue Jul 28, 2009 2:51 am
by lishawj
neo25 wrote:Here is the one I use if anyone wants it. Just edit the IP address in status.php
Server Status.rar
Hi Neo25,

Thanks for sharing the PHP script. I just download it and gave it a whirl and I have a question for you. The script is working properly and displays the uptime of the server when the LS and GS is running. However, the script returns a fsockopen error if either one of the server is down. I included the error for reference purpose.

Yes, I did modify the script picture and added a line to include the server name but that's all I did. The error is still there when using your un-modified version. Any ideas on how to have it displayed the downtime correctly?

Code: Select all

Warning: fsockopen() [function.fsockopen]: unable to connect to xxx.xxx.xxx.xxx:7777 (A connection attempt failed becausethe connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )in C:\wamp\www\status\index.php on line 17BlackBird Server StatusLoginServer - OnlineGameServer - Offline Warning: fclose(): supplied argument is not a valid stream resource inC:\wamp\www\status\index.php on line 24

Re: PHP script to know server status

Posted: Tue Jul 28, 2009 5:17 pm
by daedalus
edit status.php

at line 11 and 16 add @ before fsockopen like that

Code: Select all

$flogin = @fsockopen ("127.0.0.1",2106, $errno, $errstr, 1);

Re: PHP script to know server status

Posted: Tue Jul 28, 2009 5:30 pm
by lishawj
daedalus wrote:edit status.php

at line 11 and 16 add @ before fsockopen like that

Code: Select all

$flogin = @fsockopen ("127.0.0.1",2106, $errno, $errstr, 1);
Ah thanks, that works for me now. Thanks Daedalus!

Re: PHP script to know server status

Posted: Thu Jul 30, 2009 5:14 pm
by neo25
Sorry about that small typo and thanks daedalus. I've updated the download above.

Code: Select all

<html><head><meta http-equiv="Content-Type" content="text/html" charset="Windows-1251"><meta http-equiv="Content-Style-Type" content="text/css"><title>Status</title></head><body><?phpglobal $FORM;$FORM = "";$flogin = @fsockopen ("12.34.56.78",2106, $errno, $errstr, 1);if ( $flogin )$FORM .= "Login Server - <img src=up.png><br>";else$FORM .= "Login Server - <img src=down.png><br>";$fgame = @fsockopen ("12.34.56.78",7777, $errno, $errstr, 1);if ( $fgame )$FORM .= "Game Server - <img src=up.png><br>";else$FORM .= "Game Server - <img src=down.png><br>";echo $FORM;@fclose($flogin);@fclose($fgame);?></body></html>

Re: PHP script to know server status

Posted: Wed Jun 30, 2010 3:14 am
by slatis
I've been testing many different kinds of php scripts to know my server status, but my webhosting doesnt allow me to use "fsockopen" is there any script which uses a different way to know the status?

Re: PHP script to know server status

Posted: Wed Jun 30, 2010 9:37 am
by Vith
If you can't run a PHP without restrictions, but can run L2 server freely, consider writing a simple Java program that will check server status every minute and will publish the result to some text file or database. This way, you can also implement simple uptime stats.