1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

[WEB] Server status php script

Discussion in 'Groups & Dedicated Servers' started by LordXaosa, May 31, 2014.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. LordXaosa

    LordXaosa Apprentice Engineer

    Messages:
    148
    Hello.

    Since the dedicated servers appearance, many server-holders ask question - how to get dynamic monitoring of the server?
    Here is the answer https://dl.dropboxusercontent.com/u/39747272/steamStatus.rar
    It's php script, 99.9% based on steam-condenser script https://github.com/koraktor/steam-condenser

    I've deleted all Monolog dependencies and make it more comfortable to access data from script. All other things belongs to Sebastian Staudt.

    For example you have to change ip and port at monitor.php script and launch it.
    You can view the example here https://95.31.8.128/test/monitor.php Here I made light widget for websites or something.

    Also you can look at my signature, image dynamically rendered from script info.

    Special thanks to Sebastian Staudt for this great API!
     
    • Like Like x 1
  2. Replic TuaniOne

    Replic TuaniOne Apprentice Engineer

    Messages:
    485
    Nice work, would love to create my own one soon when I have my dedicated server running, thanks for the example :)
     
  3. Emachalaiphone

    Emachalaiphone Trainee Engineer

    Messages:
    6
    Great work i love it was testing it out on my server looks good but im missing section to load player list list yours just tell list of of like 50/100 but no player list like yours....


    Players:
    #0 "wanderermg", Score: 0, Time: 41221.4296875
    #0 "avschar", Score: 0, Time: 2091.4287109375
    #0 "Fiber!!", Score: 0, Time: 1934.7554931641
    #0 "ßatuhan.soran™", Score: 0, Time: 1829.0093994141
     
  4. LordXaosa

    LordXaosa Apprentice Engineer

    Messages:
    148
    Code:
    echo $server;
    Use this in code. Also you could check players array
    Code:
    $server->playerHash
     
  5. LordXaosa

    LordXaosa Apprentice Engineer

    Messages:
    148
    Little update :)
    I made a real-time updating picture (see my signature). It's simply continuous gif image, what frames are streamed in real time by my server. This image have no size, in fact it's unlimited.
    If you are interested in ASP.NET coding and you want something like that - pm me, I'll share the code.
     
  6. gimmilfactory

    gimmilfactory Junior Engineer

    Messages:
    523
    Steam's server browser updates, its not RT, but close.
     
  7. LordXaosa

    LordXaosa Apprentice Engineer

    Messages:
    148
    Status doesn't use steam browser at all. It request game server directly, with steam protocol. So it is RT
     
  8. dogtrigger

    dogtrigger Trainee Engineer

    Messages:
    22
    So here's a question.

    Where I have my server requiring a Steam Group ID, I'm trying to figure out where to insert that, as I think that's why I get no output (server returns nothing).

    If you have a look at lostinspace.tankology.net/monitor.php you will see what I mean.

    Thoughts ?
     
  9. TmRNL

    TmRNL Trainee Engineer

    Messages:
    9
    Would be better to set the image to refresh every 10 minutes instead of every second? My page just keeps loading and loading because of it...
     
  10. TmRNL

    TmRNL Trainee Engineer

    Messages:
    9
    Edited the script somewhat ;)
    If your forum (websites usually dont have this problem) doesnt cache like a XenForo forum does, you can use a simpel link to the .php page ;)
    [​IMG]

    Used the download link. File below is monitor.php file. Image used is this one

    Code:
    <?php
    /**
     * This code is free software; you can redistribute it and/or modify it under
     * the terms of the new BSD License.
     *
     * Copyright (c) 2010-2013, Sebastian Staudt
     *
     * @author  Sebastian Staudt
     * @license https://www.opensource.org/licenses/bsd-license.php New BSD License
     * @package steam-condenser
     */
    define('STEAM_CONDENSER_PATH', dirname(__FILE__) . '/');
    define('STEAM_CONDENSER_VERSION', '1.3.7');
    require_once STEAM_CONDENSER_PATH . 'steam/servers/GoldSrcServer.php';
    require_once STEAM_CONDENSER_PATH . 'steam/servers/MasterServer.php';
    require_once STEAM_CONDENSER_PATH . 'steam/servers/SourceServer.php';
    require_once STEAM_CONDENSER_PATH . 'steam/community/SteamId.php';
    // Set the enviroment variable for GD (just leave it be if the .ttf file in in the steamStatus folder)
    putenv('GDFONTPATH=' . realpath('.'));
    // Name the font to be used (note the lack of the .ttf extension)
    $font = 'AgencyFB-Bold.ttf';
    //Font Size
    $fontsize = 10;
    //FontAngle
    $fontangle = 0;
    //Duh..
    $fromtheleft = 265;
    try{
      $server = new GoldSrcServer('127.0.0.1', 27016);
      $server->initialize();
      $playersMax = $server->infoHash['maxPlayers'];
      $servername = $server->infoHash['serverName'];
      $playersOnline = $server->infoHash['numberOfPlayers'];
      $serverName = $server->infoHash[ 'serverName'];
      $gameVersion = $server->infoHash['gameVersion'];
      $serverIP = "149.210.163.62";
      $serverPort = $server->infoHash['serverPort'];
    
    $im = @imagecreatefrompng('./Public.png')
        or die("Cannot Initialize new GD image stream");
    $text_color = imagecolorallocate($im, 255,255,255);
    //If you need more lines, just add them. imagettftext($im, $fontsize, $fontangle, $fromtheleft, <pixels from above>, $text_color, $font, <text>);
    imagettftext($im, 14, $fontangle, $fromtheleft, 22, $text_color, $font, "Game: Space Engineers");
    imagettftext($im, $fontsize, $fontangle, $fromtheleft, 40, $text_color, $font, "Server Name ".$serverName);
    imagettftext($im, $fontsize, $fontangle, $fromtheleft, 55, $text_color, $font, "Server Adress ".$serverIP.":".$serverPort);
    imagettftext($im, $fontsize, $fontangle, $fromtheleft, 70, $text_color, $font, "Status: Online");
    imagettftext($im, $fontsize, $fontangle, $fromtheleft, 85, $text_color, $font, "Players ".$playersOnline."/".$playersMax."");
    imagettftext($im, $fontsize, $fontangle, $fromtheleft, 100, $text_color, $font, "Version: ".$gameVersion);
    header("Content-Type: image/png");
    /* Only for transparent PNG's
    $trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
        imagesavealpha($im, true);
        imagefill($im, 0, 0, $trans);
    */
    imagepng($im);
    imagedestroy($im);
      }
      catch(Exception $e)
      {
    $im = @imagecreatefrompng('./Public.png')
        or die("Cannot Initialize new GD image stream");
    $text_color = imagecolorallocate($im, 255, 0, 0);
    imagettftext($im, 14, $fontangle, $fromtheleft, 22, $text_color, $font, "Game: Space Engineers");
    imagettftext($im, 20, $fontangle, $fromtheleft, 70, $text_color, $font, "Server Offline");
    header("Content-Type: image/png");
    /* Only for transparent PNG's
    $trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
        imagesavealpha($im, true);
        imagefill($im, 0, 0, $trans);
    */
    imagepng($im);
    imagedestroy($im);
        
      }
    
    
    ?>
    
     
  11. LordXaosa

    LordXaosa Apprentice Engineer

    Messages:
    148
    Well, it's realtime GIF image, to simply show the abilities :) Of course I can do a cached image, that refresh every 10+ minutes.
    Also thanks for your php image generator via this library! Good job! :)
     
  12. TmRNL

    TmRNL Trainee Engineer

    Messages:
    9
    Thnx for the praise ;)
    Will update the script soon and make it a little neater ;) so you only need to fill in server ip + port once ;)
    This image updates everytime you refresh the page since you use the img tags on a .php link.
    Code:
    [/img]https://www.tijmenschoemaker.nl/steamStatus/monitor.php[/img]  
     
  13. TmRNL

    TmRNL Trainee Engineer

    Messages:
    9
    Somehow my script stopped working :( doh...
     
  14. TmRNL

    TmRNL Trainee Engineer

    Messages:
    9
    Never mind, seems 127.0.0.1 wasnt working anymore :p
     
  15. LordXaosa

    LordXaosa Apprentice Engineer

    Messages:
    148
    Hm... As for me I'm using my local home-network address. Like steam observer operates with...
     
  16. xphoenixxx

    xphoenixxx Junior Engineer

    Messages:
    529
    I am trying to get this to work - But im feeling like a noob here..
    Trouble is it always shows as offline for my server..
    I have my main website hosting the script.

    I have my separate dedicated server running the actual game.

    I've added the ip/port of my game server into monitor.php -
    Script loads but all i ever get back is "offline" so what am i missing here ?

    --

    Ok further progress; forgot a firewall setting - now I get:
    Warning: socket_send() [function.socket-send]: unable to write to socket [1]: Operation not permitted in /home/www/our-game.net/spaceengineers/steamStatus/Socket.php on line 163
    Offline

    I am guessing that you require sockets for php enabled.. correct me if I am wrong..
     
    Last edited by a moderator: Dec 18, 2014
  17. LordXaosa

    LordXaosa Apprentice Engineer

    Messages:
    148
    Yes, you are right. You should ask your hoster to enable sockets in php.
     
  18. TangentSpy

    TangentSpy Trainee Engineer

    Messages:
    1
    [img]https://status.our-game.net/banner.php[/img]
     
  19. xphoenixxx

    xphoenixxx Junior Engineer

    Messages:
    529
    As you guessed by my signature suddenly working we got it working on a local server.. then customized it.
    Looks like my usual host is just on crack or something and probably blocks the required protocols.
    Thanks for the great script.
     
  20. Katai

    Katai Trainee Engineer

    Messages:
    2
    First off, thanks for the script. So far, it has been incredibly useful.

    I am running into one issue, though. The number of players appears to be showing up fine, but I can't seem to get any play information (I mainly just want a list of logged in players). The var_dump has this.
    Code:
      ["playerHash"]=>NULL
    
    Any reason why this is coming back null?
     
  21. Katai

    Katai Trainee Engineer

    Messages:
    2
    First off, thanks for the script. It seems to work wonderfully.

    One problem, though. It seems like ["playerHash"] is coming back null. Do you have any idea why that might be happening? I'm just trying to get a list of players.
     
  22. Thorium

    Thorium Trainee Engineer

    Messages:
    19
    I have the same problem.
    Did someone figured this out?
     
  23. Xemos

    Xemos Trainee Engineer

    Messages:
    61
    Anyone have a working website with this running? Would love to see it in action before I got on a multi-day headache to implement it into a wordpress site.
     
  24. Thorium

    Thorium Trainee Engineer

    Messages:
    19
    I do, but it's for friends only. I dont want to post the link in public and i can't start a private conversation with you on the forum. It gives me an error.

    btw.: It's working with ME as well. But still not possible to query player names.
     
  25. Xemos

    Xemos Trainee Engineer

    Messages:
    61
    Can send me a steam message :D Click the owl below my name on left. Would love to see how it works, currently we are using those banners from space-engineers.com.. www.aphoticowl.com ( it's a WIP site so pardon it's messiness lol ) Would love to be able to show players in server in the server tab on main page. Does it work in that context?
     
  26. Thorium

    Thorium Trainee Engineer

    Messages:
    19
    No. For some reason player names can't be queried with the current SE version.
     
  27. Mash

    Mash Trainee Engineer

    Messages:
    88
    I'm getting this PHP config. error when executing.
    Code:
    Warning: socket_select() [function.socket-select]: You MUST recompile PHP with a larger value of FD_SETSIZE.
    It is set to 1024, but you have descriptors numbered at least as high as 1855.
    --enable-fd-setsize=2048 is recommended, but you may want to set it to equal the maximum number of open files supported by your system, in order to avoid seeing this error again at a later date.
    in /home/~/Socket.php on line 147
    Tech support of my web host told me it's not possible for them to adjust that default value for their shared hosting servers. :/
    But their Virtual Private Server (VPS) does have this ability. -.-

    *dusts of an old Intel pico PC, to setup a private host
     
    Last edited: Dec 2, 2015
Thread Status:
This last post in this thread was made more than 31 days old.