MineLink 0.1

Discussion in 'Bukkit Help' started by MonsieurApple, Feb 6, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    MonsieurApple

    MineLink v. 0.1 ~ Download
    Compatible with BukkitTcpServer v1.0.

    Hey everyone, a while back I made a PHP Class that connects to the plugin BukkitTcpServer by DerpinLlama and have just now decided to release it.

    Right now it supports the following commands:
    • getplayers
    • maxplayers
    • pid
    • playercount
    But I'm planning on adding more in the future.

    In the ZIP there is the Class file, a Config file, and a Usage file. Hopefully this will get everyone started right.

    This program is released under the terms of the GNU GPL v3. You will find the license in the ZIP file.
     
  2. Offline

    DerpinLlama

    This is a class designed to connect to the plugin. Not a wrapper.
     
  3. Offline

    MonsieurApple

    Excuse my terminology.
     
  4. Offline

    cyberbobjr

    Hi,
    really nice, thank you for your job.
    Do you envisage to made a PHP Bukkit admin ?
    If not i'm working on it.
    Best regards.
    Cyb
     
  5. Offline

    MonsieurApple

    Yes, I have one in the works.
     
  6. Offline

    cyberbobjr

    Hi,
    i've made some modifications on your PHP class, are you interested by there ?
     
  7. Offline

    MonsieurApple

    It's GPL so you can post them. If I see then Fitting I'll add them.

    Also after releasing it I noticed there were a ton of bugs. I'll release 0.2 tonight.
     
  8. Offline

    awem

    Just what I needed, thanks.
     
  9. Offline

    cyberbobjr

    Hi,
    thanks for your job, i'm waiting this release with impatience :p
     
  10. Offline

    Abadon84

    perhaps it is postet already... in the usage.php are some syntax errors and in the minelink.php the funtion players returns $data['message'] instead of the right $data['players']. greetings abadon

    edit:
    instead of the echo for players in the usage php you should use
    <?php $players = $link->players(); foreach($players as $player){echo $player.' ';} ?>
     
    dragonhib likes this.
  11. Offline

    MonsieurApple

    I realized this when I released it. Still haven't gotten around to updating it. Maybe later today...
     
  12. Offline

    Abadon84

    Mhhh, i have still a problem with the server usage... we are running a debian server and the the minelink class doesn´t show me me the usage of the cpu and memory... does anyone knows this problem and perhaps how to fix it?
    greetings abadon
     
  13. Offline

    MonsieurApple

    It was only tested on ubuntu. Do you have the 'ps' command?
     
  14. Offline

    Abadon84

    if i type the comand directly in the server console it works but called by the exec of the class it doesn´t work...
     
  15. Offline

    MonsieurApple

    Check your PHP ini settings. Safe mode could be on.
     
  16. Offline

    Abadon84

    safe mode is off, here the server mesage wenn i type manually... i check the php.ini again

    noki@91-143-80-71:~$ ps -p 32502 -o %cpu
    %CPU
    82.0

    EDIT:
    safemode is off
    disable_functions is empty
    --- merged: Feb 27, 2011 10:25 PM ---
    OMG epic fail.... it must running on this server^^ i modify it so that it works from remote...
    --- merged: Feb 27, 2011 10:56 PM ---
    i have solved it with ssh2_lib... btw in the minelink.php $minecraft['memorylimit'] is not declared as class variable... because of that it can't use it in memoryusage

    here the example code for cpu usage with ssh2 lib mem usage is nearly the same:
    PHP:
    // log in at server1.example.com on port 22
    if(!($con ssh2_connect('server-ip'22))){
        echo 
    "fail: unable to establish connection\n";
    } else {
        
    // try to authenticate with username root, password secretpassword
        
    if(!ssh2_auth_password($con'username''password')) {
            echo 
    "fail: unable to authenticate\n";
        } else {
            if (!(
    $stream ssh2_exec($con'ps -p '$this->pid .' -o %cpu' ))) {
                echo 
    "fail: unable to execute command\n";
            } else {
                
    // collect returning data from command
                
    stream_set_blocking($streamtrue);
                
    $data "";
                while (
    $buf fread($stream,4096)) {
                    
    $data .= $buf;
                }
                
    fclose($stream);
            }
        }
    }
            
    $return explode("\n"$data);
            if(!
    $return[1]) $return[1] = '0';
            return 
    $return[1];
     
  17. Offline

    MonsieurApple

    Nice, glad you got it working!

    About the memorylimit, it's just however much memory you gave your server at startup with XmX
     
  18. Offline

    Abadon84

    yes but so it is you got a division by zero if you call mem_usage
     
  19. Offline

    MonsieurApple

    Just define it as how much memory you give it and it will be gone :p
     
  20. Offline

    Abadon84

    so it is in the function mem_usage:
    return ($return[1] / 1024) / $minecraft['memorylimit'] * 100; but it can't reach the variable
    so it works if it is set as class variable:
    return ($return[1] / 1024) / $this->minecraft['memorylimit'] * 100;
     
  21. Offline

    MonsieurApple

    Glad its working ;P
     
  22. Offline

    Abadon84

    i have added a new function to show the server uptime, if you like it put it in the new release ;)
    PHP:
    public function uptime()
    {
        
    $return explode("\n"shell_exec'ps -p '$this->pid .' -o %t' ));
        if(!
    $return[1])
        {
                    
    $return '0';
        }
        else
        {
                    
    $return explode(":"$return[1]);
                    if (
    count($return) == 3)   {$return $return[0].'h '.$return[1].'m '.$return[2].'s';}
                    elseif(
    count($return) == 2){$return $return[0].'m '.$return[1].'s';}
                    elseif(
    count($return) == 1){$return $return.'s';}
                }
        return 
    $return;
    }
     
  23. Offline

    MonsieurApple

    Very nice! I will consider adding it :)
     
  24. Offline

    Abadon84

    UPDATE UPTIME:
    this will only work if the server is running less than an hour^^ here the correct code:
    PHP:
    public function uptime()
    {
        
    $return explode("\n"shell_exec'ps -p '$this->pid .' -o %t' ));
        if(!
    $return[1])
        {
                    
    $return '0';
        }
        else
        {
                    
    $return explode(":"$return[1]);
                    if (
    count($return) == 3) {$return $return[0].'h '.$return[1].'m '.$return[2].'s';}
                    elseif(
    count($return) == 2){$return[0].'m '.$return[2].'s';}
                    elseif(
    count($return) == 1){$return.'s';}
                }
        return 
    $return;
    }
    perhaps it adds days to the reply if the server runs so long, in case of that another if must be added... i will watch it.
    without formatting the otput will be hh:mm:ss but if the server is running lesser than an hour or a minute the reply didn`t show the zeros...
     
  25. Offline

    MonsieurApple

    Very nice :p

    I will for sure update this later today :p
     
  26. Offline

    Kanuuu

    Can you please reupload the class?
    The Downloadlink doesnt work for me....

    Big Thanks
     
  27. Offline

    MonsieurApple

  28. Offline

    Kanuuu

    very big thanks ;)
     
Thread Status:
Not open for further replies.

Share This Page