PHP script to know server status
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 23
- Joined: Sat Jul 04, 2009 7:52 pm
PHP script to know server status
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??
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??
- janiii
- L2j Veteran
- Posts: 4269
- Joined: Wed May 28, 2008 3:15 pm
- Location: Slovakia
Re: PHP script to know server status
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!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
- momo61
- Posts: 1648
- Joined: Fri Jun 06, 2008 2:05 pm
- Location: Europe
Re: PHP script to know server status
i kinda need a server status script
-
- Posts: 39
- Joined: Fri Apr 04, 2008 3:46 am
Re: PHP script to know server status
Code: Select all
if ( @fsockopen ($IP, 7777, $errno, $errstr, 1) )
-
- Posts: 23
- Joined: Sat Jul 04, 2009 7:52 pm
Re: PHP script to know server status
Thx... you've benn very useful.. once i'll terimante my scripts, i will host them.. and share with the forum..
-
- Posts: 271
- Joined: Wed Mar 19, 2008 10:16 am
Re: PHP script to know server status
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)
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)
-
- Posts: 23
- Joined: Sat Jul 04, 2009 7:52 pm
Re: PHP script to know server status
Ok, i made the script, but my Webhosting service.. deny fsockopen() function, so i can't test it...
-
- Posts: 271
- Joined: Wed Mar 19, 2008 10:16 am
Re: PHP script to know server status
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
-
- Posts: 26
- Joined: Sun Jul 09, 2006 7:53 pm
Re: PHP script to know server status
Here is the one I use if anyone wants it. Just edit the IP address in status.php
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.
-
- Posts: 253
- Joined: Thu Apr 30, 2009 12:29 am
Re: PHP script to know server status
Hi Neo25,neo25 wrote:Here is the one I use if anyone wants it. Just edit the IP address in status.php
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
- daedalus
- Posts: 155
- Joined: Sun Mar 12, 2006 12:16 pm
Re: PHP script to know server status
edit status.php
at line 11 and 16 add @ before fsockopen like that
at line 11 and 16 add @ before fsockopen like that
Code: Select all
$flogin = @fsockopen ("127.0.0.1",2106, $errno, $errstr, 1);
Daedalus
-
- Posts: 253
- Joined: Thu Apr 30, 2009 12:29 am
Re: PHP script to know server status
Ah thanks, that works for me now. Thanks Daedalus!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);
-
- Posts: 26
- Joined: Sun Jul 09, 2006 7:53 pm
Re: PHP script to know server status
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>
-
- Posts: 2
- Joined: Sun Apr 29, 2007 5:47 pm
Re: PHP script to know server status
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?
- Vith
- Posts: 11
- Joined: Mon Jun 28, 2010 2:17 pm
- Location: Poland
- Contact:
Re: PHP script to know server status
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");
while (me.getSpareTime() > 0)
{
me.playLineage();
}
printf("Another nonconstructive day (-;\n");