Page 1 of 1

Getting Current CPU Usage

Posted: Sun Sep 03, 2006 9:19 pm
by Tommaso
I am having some trouble using PHP to get the current CPU usage of my computer. This is what i have tried so far, but $Output never fills

Attempt 1 (Using linux command top)

Code: Select all

exec('top -i -n 1', $Output);
echo 'Process Output:';
foreach($Output as $Key => $Value)
{
echo $Key;
}
Attempt 2 (Using linux command ps)

Code: Select all

exec('ps -ax', $Output);
echo 'Process Output:';
foreach($Output as $Key => $Value)
{
echo $Key;
}
Any help or suggestions would be appreciated.

Posted: Sun Sep 03, 2006 9:37 pm
by sweatje
Perhaps you should try echoing $Value instead ;)

Posted: Sun Sep 03, 2006 9:40 pm
by Tommaso
I think i am going to bang my head agains the screen for 5 minutes now....Thanks for the help :)