d22552000 Posted October 8, 2007 Share Posted October 8, 2007 Even though this is not QUITE related to a webserver, some webservers return the usage% in a sys variable but mine doesnt. How would I get the cpu usage from the commandline or in my php script? like I could say: if ($CPUSG > 75) { error_msg('The server is busy processing user's requests. Please try again later.',500); } But how would I get the cpu usage? Quote Link to comment https://forums.phpfreaks.com/topic/72271-solved-cpu-non-linux/ Share on other sites More sharing options...
tomfmason Posted October 8, 2007 Share Posted October 8, 2007 when you say "non linux" I am assuming that you mean windows, correct? If so you can use wmi with COM. Like this.. <?php $wmi = new COM('winmgmts://'); $processor = $wmi->ExecQuery("SELECT * FROM Win32_Processor"); foreach($processor as $obj){ $cpu_load = $obj->LoadPercentage; } if($cpu_load > 75) { //do something } ?> For more info see http://msdn2.microsoft.com/en-us/library/aa394373.aspx Quote Link to comment https://forums.phpfreaks.com/topic/72271-solved-cpu-non-linux/#findComment-364600 Share on other sites More sharing options...
d22552000 Posted October 8, 2007 Author Share Posted October 8, 2007 well woudl ya look at that... a perfect solution. Thank's man. Quote Link to comment https://forums.phpfreaks.com/topic/72271-solved-cpu-non-linux/#findComment-364889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.