Don't forget that CPU load on *ix doesn't equate directly to utilisation as windows understands it
Load is more to do with how much stuff is waiting rather than how much work the CPU is actually doing, if that makes sense?
However, using the COM extension (http://uk3.php.net/manual/en/book.com.php
) you could query the WMI without using exec(), and just barf if the extension isn't loaded (http://uk.php.net/extension_loaded
), although most windows versions of PHP should have it by default, unless it's been custom compiled
$obj = new COM ( 'winmgmts://./root/cimv2' );
$pc = 0;
foreach ( $obj->instancesof ( 'Win32_Processor' ) as $p )
printf("CPU%d @ %d%%", $pc++, $p->LoadPercentage);
That'll work fine if you're using a regular user account like you would be with PRISM (well, tested with a w2003 box, I've not got a w2008 box spun up right this second, but I don't see why it wouldn't work - I'm not aware of any changes in the default perms for WMI under that).
However, if you want to run that as your webserver user, unless you're running your webserver with access to the WMI it'll fail like a bastard. For example, using IIS with an anonymous user the WMI root/cimv2 permissions would need the IUSR_MACHINENAME or IUSR account added with remote enable permissions.
There are, naturally, possible security problems in making your webserver able to poke at WMI