function provision_load_critical

7.x-3.x provision.drush.inc provision_load_critical($load = NULL, $threshold = NULL)

determine if overall load of the machine is critical

We use the "average system load" of the system as a metric, as available through 'uptime' or in PHP sys_getloadavg() since 5.1. The load is usually defined as "the number of processes in the system run queue"

It's not a really reliable metric, but it's the best shot we've got without getting into real specific details about I/O, CPU or memory load that are going to be even tougher to evaluate.

We base our evaluation on the number of CPUs on the servers. If there are more than 5 processes waiting per CPU, we abort completely. If we ignore the number of available CPUs, we assume a critical limit is a load of 10.

See also

sys_getloadavg()

Related topics

1 call to provision_load_critical()
_provision_drush_check_load in ./provision.drush.inc
This will abort any process running drush if the load is critical.

File

./provision.drush.inc, line 450
Provision Drush commands.

Code

function provision_load_critical($load = NULL, $threshold = NULL) {
  if (is_null($load)) {
    $load = sys_getloadavg();
  }
  if (is_null($threshold)) {
    if ($ncpus = provision_count_cpus()) {
      $threshold = $ncpus * drush_get_option('critical_load_multiplier', CRITICAL_LOAD_MULTIPLIER);
    }
    else {
      // can't determine the number of CPU, we hardcode at load 10
      $threshold = drush_get_option('critical_load_threshold', CRITICAL_LOAD_THRESHOLD);
    }
  }
  return ($load[0] > $threshold);
}