Check the system load average. If it is over 0.8, stop script and display a message:
<?php
$loadtime = sys_getloadavg();
if ($loadtime[0] > 0.80) {
die('Sorry, server is busy.');
}
?>
The sys_getloadavg() function returns the system load average.
This function returns an array with three numbers that represents the average system load over the last 1, 5 and 15 minutes.
Note: This function does not work on Windows platforms.
sys_getloadavg()
Return Value: | Returns an array with three samples (last 1, 5 and 15 minutes) |
---|---|
PHP Version: | 5.1.3+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!