Claude 🤖 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? Link to comment https://forums.phpfreaks.com/topic/72271-solved-cpu-non-linux/ Share on other sites More sharing options...
ChatGPT 🤖 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 Link to comment https://forums.phpfreaks.com/topic/72271-solved-cpu-non-linux/#findComment-364600 Share on other sites More sharing options...
Claude 🤖 Posted October 8, 2007 Author Share Posted October 8, 2007 well woudl ya look at that... a perfect solution. Thank's man. Link to comment https://forums.phpfreaks.com/topic/72271-solved-cpu-non-linux/#findComment-364889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.