Re: [PHP] Re: System specific information gathering

2005-07-24 Thread André Medeiros
Or that... :P

On 7/24/05, Joe Wollard [EMAIL PROTECTED] wrote:
 As always, look for someone else's existing project and see how they
 did it. ;-)
 
 http://phpsysinfo.sourceforge.net/
 
 Good Luck!
 -Joe
 
 On Jul 23, 2005, at 9:25 AM, André Medeiros wrote:
 
  First of all, you want to have the two values in seperate variables.
  After reading the contents from the file, do something like:
 
  -8---
  --
  function parseUptimeSeconds( $seconds ) {
  $resultArray = Array( 'weeks' = 0, 'days' = 0, 'hours' = 0,
  'minutes' = 0, 'seconds' =  0);
 
  // check weeks
  while( $seconds  604800 ) {
  $resultArray['weeks']++;
  $seconds -= 604800;
  }
 
  // check days
  while( $seconds  86400) {
  $resultArray['days']++;
  $seconds -= 86400;
  }
 
  // check hours
  while( $seconds  3600) {
  $resultArray['hours']++;
  $seconds -= 3600;
  }
 
  // check minutes
  while( $seconds  60) {
  $resultArray['minutes']++;
  $seconds -= 60;
  }
 
  $resultArray['seconds'] = $seconds;
 
  return( $resultArray );
  }
 
  // separate both values
  list( $uptimeSeconds, $idleSeconds ) = explode( ' ',
  $lineReadFromFile );
  $uptimeElements = parseUptimeSeconds( $uptimeSeconds );
  $idleElements = parseUptimeSeconds( $idleSeconds );
  -8---
  --
 
  I know there might be a more efficient way of doing this, like using
  the modulus operator, but hey :)
 
  On 7/23/05, Ramil Sagum [EMAIL PROTECTED] wrote:
 
  On 7/23/05, Vidyut Luther [EMAIL PROTECTED] wrote:
 
  Ok,
If I use the file_get_contents.. how do I actually parse the
  contents on /proc/uptime
  cat /proc/uptime
  1400293.13 1317047.64
 
 
 
  The first number is the total uptime in seconds, the second number is
  the total idle time.
 
  --
  
 
 
 
  ramil
  http://ramil.sagum.net/
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: System specific information gathering

2005-07-23 Thread André Medeiros
First of all, you want to have the two values in seperate variables.
After reading the contents from the file, do something like:

-8-
function parseUptimeSeconds( $seconds ) {
$resultArray = Array( 'weeks' = 0, 'days' = 0, 'hours' = 0,
'minutes' = 0, 'seconds' =  0);

// check weeks
while( $seconds  604800 ) {
$resultArray['weeks']++;
$seconds -= 604800;
}

// check days
while( $seconds  86400) {
$resultArray['days']++;
$seconds -= 86400;
}

// check hours
while( $seconds  3600) {
$resultArray['hours']++;
$seconds -= 3600;
}

// check minutes
while( $seconds  60) {
$resultArray['minutes']++;
$seconds -= 60;
}

$resultArray['seconds'] = $seconds;

return( $resultArray );
}

// separate both values
list( $uptimeSeconds, $idleSeconds ) = explode( ' ', $lineReadFromFile );
$uptimeElements = parseUptimeSeconds( $uptimeSeconds );
$idleElements = parseUptimeSeconds( $idleSeconds );
-8-

I know there might be a more efficient way of doing this, like using
the modulus operator, but hey :)

On 7/23/05, Ramil Sagum [EMAIL PROTECTED] wrote:
 On 7/23/05, Vidyut Luther [EMAIL PROTECTED] wrote:
  Ok,
If I use the file_get_contents.. how do I actually parse the
  contents on /proc/uptime
  cat /proc/uptime
  1400293.13 1317047.64
 
 
 The first number is the total uptime in seconds, the second number is
 the total idle time.
 
 --
 
 
 
 
 ramil
 http://ramil.sagum.net/
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: System specific information gathering

2005-07-23 Thread Joe Wollard
As always, look for someone else's existing project and see how they  
did it. ;-)


http://phpsysinfo.sourceforge.net/

Good Luck!
-Joe

On Jul 23, 2005, at 9:25 AM, André Medeiros wrote:


First of all, you want to have the two values in seperate variables.
After reading the contents from the file, do something like:

-8--- 
--

function parseUptimeSeconds( $seconds ) {
$resultArray = Array( 'weeks' = 0, 'days' = 0, 'hours' = 0,
'minutes' = 0, 'seconds' =  0);

// check weeks
while( $seconds  604800 ) {
$resultArray['weeks']++;
$seconds -= 604800;
}

// check days
while( $seconds  86400) {
$resultArray['days']++;
$seconds -= 86400;
}

// check hours
while( $seconds  3600) {
$resultArray['hours']++;
$seconds -= 3600;
}

// check minutes
while( $seconds  60) {
$resultArray['minutes']++;
$seconds -= 60;
}

$resultArray['seconds'] = $seconds;

return( $resultArray );
}

// separate both values
list( $uptimeSeconds, $idleSeconds ) = explode( ' ',  
$lineReadFromFile );

$uptimeElements = parseUptimeSeconds( $uptimeSeconds );
$idleElements = parseUptimeSeconds( $idleSeconds );
-8--- 
--


I know there might be a more efficient way of doing this, like using
the modulus operator, but hey :)

On 7/23/05, Ramil Sagum [EMAIL PROTECTED] wrote:


On 7/23/05, Vidyut Luther [EMAIL PROTECTED] wrote:


Ok,
  If I use the file_get_contents.. how do I actually parse the
contents on /proc/uptime
cat /proc/uptime
1400293.13 1317047.64




The first number is the total uptime in seconds, the second number is
the total idle time.

--




ramil
http://ramil.sagum.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: System specific information gathering

2005-07-22 Thread Jasper Bryant-Greene

Vidyut Luther wrote:

Hello,
 I have a question on how to get Server side system specific  
information via PHP, or just general direction on how to parse some  of 
the information found in /proc


I just use file_get_contents() on the files in /proc. I would expect 
that would be a lot faster than using system() to execute 'uptime' etc.


Jasper

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: System specific information gathering

2005-07-22 Thread Vidyut Luther

Ok,
 If I use the file_get_contents.. how do I actually parse the  
contents on /proc/uptime

cat /proc/uptime
1400293.13 1317047.64

What do I do with those two numbers ?

man uptime doesn't really talk about that file.. :/



On Jul 22, 2005, at 2:42 AM, Jasper Bryant-Greene wrote:


Vidyut Luther wrote:


Hello,
 I have a question on how to get Server side system specific   
information via PHP, or just general direction on how to parse  
some  of the information found in /proc




I just use file_get_contents() on the files in /proc. I would  
expect that would be a lot faster than using system() to execute  
'uptime' etc.


Jasper

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: System specific information gathering

2005-07-22 Thread Ramil Sagum
On 7/23/05, Vidyut Luther [EMAIL PROTECTED] wrote:
 Ok,
   If I use the file_get_contents.. how do I actually parse the
 contents on /proc/uptime
 cat /proc/uptime
 1400293.13 1317047.64


The first number is the total uptime in seconds, the second number is
the total idle time.

-- 




ramil
http://ramil.sagum.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php