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
Tommaso
Forum Newbie
Posts: 5 Joined: Sat Sep 02, 2006 2:07 am
Post
by Tommaso » Sun Sep 03, 2006 9:19 pm
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.
sweatje
Forum Contributor
Posts: 277 Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA
Post
by sweatje » Sun Sep 03, 2006 9:37 pm
Perhaps you should try echoing $Value instead
Tommaso
Forum Newbie
Posts: 5 Joined: Sat Sep 02, 2006 2:07 am
Post
by Tommaso » Sun Sep 03, 2006 9:40 pm
I think i am going to bang my head agains the screen for 5 minutes now....Thanks for the help