PHP script to know server status

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
matteppi
Posts: 23
Joined: Sat Jul 04, 2009 7:52 pm

PHP script to know server status

Post 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??
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: PHP script to know server status

Post by janiii »

search for other php scripts. there are enough out there :)
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
momo61
Posts: 1648
Joined: Fri Jun 06, 2008 2:05 pm
Location: Europe

Re: PHP script to know server status

Post by momo61 »

i kinda need a server status script :o
lantoc
Posts: 39
Joined: Fri Apr 04, 2008 3:46 am

Re: PHP script to know server status

Post by lantoc »

Code: Select all

if ( @fsockopen ($IP, 7777, $errno, $errstr, 1) )
matteppi
Posts: 23
Joined: Sat Jul 04, 2009 7:52 pm

Re: PHP script to know server status

Post by matteppi »

Thx... you've benn very useful.. once i'll terimante my scripts, i will host them.. and share with the forum..
Vapulabe
Posts: 271
Joined: Wed Mar 19, 2008 10:16 am

Re: PHP script to know server status

Post 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)
matteppi
Posts: 23
Joined: Sat Jul 04, 2009 7:52 pm

Re: PHP script to know server status

Post by matteppi »

Ok, i made the script, but my Webhosting service.. deny fsockopen() function, so i can't test it...
Vapulabe
Posts: 271
Joined: Wed Mar 19, 2008 10:16 am

Re: PHP script to know server status

Post 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
neo25
Posts: 26
Joined: Sun Jul 09, 2006 7:53 pm

Re: PHP script to know server status

Post by neo25 »

Here is the one I use if anyone wants it. Just edit the IP address in status.php
Server Status.rar
You do not have the required permissions to view the files attached to this post.
Last edited by neo25 on Thu Jul 30, 2009 5:22 pm, edited 1 time in total.
lishawj
Posts: 253
Joined: Thu Apr 30, 2009 12:29 am

Re: PHP script to know server status

Post 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
User avatar
daedalus
Posts: 155
Joined: Sun Mar 12, 2006 12:16 pm

Re: PHP script to know server status

Post 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);
Daedalus
lishawj
Posts: 253
Joined: Thu Apr 30, 2009 12:29 am

Re: PHP script to know server status

Post 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!
neo25
Posts: 26
Joined: Sun Jul 09, 2006 7:53 pm

Re: PHP script to know server status

Post 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>
slatis
Posts: 2
Joined: Sun Apr 29, 2007 5:47 pm

Re: PHP script to know server status

Post 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?
User avatar
Vith
Posts: 11
Joined: Mon Jun 28, 2010 2:17 pm
Location: Poland
Contact:

Re: PHP script to know server status

Post 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.
me = new Geek();
while (me.getSpareTime() > 0)
{
me.playLineage();
}
printf("Another nonconstructive day (-;\n");
Post Reply