return true;
}
+
+function current_load() {
+ if (!function_exists('sys_getloadavg'))
+ return false;
+
+ $load_arr = sys_getloadavg();
+
+ if (!is_array($load_arr))
+ return false;
+
+ return max($load_arr);
+}
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
- if(function_exists('sys_getloadavg')) {
- $load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
- logger('system: load ' . $load[0] . ' too high. cron deferred to next scheduled run.');
+
+ $load = current_load();
+ if($load) {
+ if(intval($load) > $maxsysload) {
+ logger('system: load ' . $load . ' too high. cron deferred to next scheduled run.');
return;
}
}
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
- if(function_exists('sys_getloadavg')) {
- $load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
- logger('system: load ' . $load[0] . ' too high. Cronhooks deferred to next scheduled run.');
+
+ $load = current_load();
+ if($load) {
+ if(intval($load) > $maxsysload) {
+ logger('system: load ' . $load . ' too high. Cronhooks deferred to next scheduled run.');
return;
}
}
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
- if(function_exists('sys_getloadavg')) {
- $load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
- logger('system: load ' . $load[0] . ' too high. Delivery deferred to next queue run.');
+
+ $load = current_load();
+ if($load) {
+ if(intval($load) > $maxsysload) {
+ logger('system: load ' . $load . ' too high. Delivery deferred to next queue run.');
return;
}
}
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
- if(function_exists('sys_getloadavg')) {
- $load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
- logger('system: load ' . $load[0] . ' too high. discover_poco deferred to next scheduled run.');
+
+ $load = current_load();
+ if($load) {
+ if(intval($load) > $maxsysload) {
+ logger('system: load ' . $load . ' too high. discover_poco deferred to next scheduled run.');
return;
}
}
unset($db_host, $db_user, $db_pass, $db_data);
};
- if(function_exists('sys_getloadavg')) {
+ $load = current_load();
+ if($load) {
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
- $load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
- logger('system: load ' . $load[0] . ' too high. poller deferred to next scheduled run.');
+ if(intval($load) > $maxsysload) {
+ logger('system: load ' . $load . ' too high. poller deferred to next scheduled run.');
return;
}
}
$active = poller_active_workers();
// Decrease the number of workers at higher load
- if(function_exists('sys_getloadavg')) {
- $load = max(sys_getloadavg());
-
+ $load = current_load();
+ if($load) {
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
$maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
if($maxsysload_frontend < 1)
$maxsysload_frontend = 50;
- if(function_exists('sys_getloadavg')) {
- $load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload_frontend) {
- logger('system: load ' . $load[0] . ' too high. Service Temporarily Unavailable.');
+
+ $load = current_load();
+ if($load) {
+ if($load > $maxsysload_frontend) {
+ logger('system: load ' . $load . ' too high. Service Temporarily Unavailable.');
header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
header('Retry-After: 300');
die("System is currently unavailable. Please try again later");