Getting Server info Using by sending commands

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
astropirate
Forum Newbie
Posts: 12
Joined: Tue Oct 28, 2008 3:59 pm

Getting Server info Using by sending commands

Post by astropirate »

Hello all;
i am trying to make a little server stat signiture. currently i am trying to get the info from my server using php (obviously i have never done) now i started my little game server and ran WPE PRO on it, it showe that when it receives the command

Code: Select all

../status.
it sends the server stats. my question is that how might one implement this in php?
so far i have this: (i do not know if i am on the right track.)

Code: Select all

 
 
<?php
 
$handle = fsockopen('192.168.1.2', 3558, $erno, $errstr, 15);
if (!$handle) {
  //if connection fails exit and tell us what went wrong.
  die("Connect failed:its all your falut!!!! jerk! $errstr\n");
}
else {
  $message = "../whatmap.\n";
  //read the first responds the server gives us (usually the version string)
 
 
  //send our data to the game server
  
  
   
  fwrite($handle, "$message");
 $responses = fgets($handle, 20);
  /*
   until there is no more output to read from the smtp server keep storing all the output
   in the $responses variable. Once there's nothing else to read show us all the output
   and exit
  */
 while (!feof($handle)) {
     $responses .= fgets($handle, 20);
 }
 
  echo "$responses";
 
  fclose($handle);
}
?> 
 
this code is from a tutorial modified by me (some what)

i would greatly appreciate any help at all.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Getting Server info Using by sending commands

Post by s.dot »

Perhaps the functions getrusage(), memory_get_usage(), memory_get_peak_usage(), and some other functions listed here: http://us3.php.net/manual/en/ref.info.php would be useful

And disk_free_space() and disk_total_space() and some other functions listed here: http://us3.php.net/manual/en/ref.filesystem.php
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
astropirate
Forum Newbie
Posts: 12
Joined: Tue Oct 28, 2008 3:59 pm

Re: Getting Server info Using by sending commands

Post by astropirate »

Ohh i forgot to actually mention, but that code i have up there, didnt do much it just gave me an empty page.
Post Reply