You are here

function monitoring_sensor_run_multiple in Monitoring 8

Same name and namespace in other branches
  1. 7 monitoring.module \monitoring_sensor_run_multiple()

Runs sensors.

Parameters

array $sensor_names: Sensor names to run.

bool $force_run: Flag to force run.

bool $verbose: (optional) Set to TRUE to enable verbose execution, defaults to FALSE.

Return value

\Drupal\monitoring\Result\SensorResultInterface[] List of result objects.

Throws

\Drupal\monitoring\Sensor\NonExistingSensorException Thrown if the requested sensor does not exist.

\Drupal\monitoring\Sensor\DisabledSensorException Thrown if any of the passed sensor names is not enabled.

See also

\Drupal\monitoring\Sensor\SensorManager

\Drupal\monitoring\SensorRunner

3 calls to monitoring_sensor_run_multiple()
MonitoringCommands::run in src/Commands/MonitoringCommands.php
Runs all sensors or a specific sensor and provides verbose data.
monitoring_drush_run in ./monitoring.drush.inc
Drush callback to get sensor results.
monitoring_sensor_run in ./monitoring.module
The sensor runner function.

File

./monitoring.module, line 164
Monitoring bootstrap file.

Code

function monitoring_sensor_run_multiple($sensor_names = array(), $force_run = FALSE, $verbose = FALSE) {
  $sensors_config = array();
  if (empty($sensor_names)) {
    foreach (monitoring_sensor_manager()
      ->getEnabledSensorConfig() as $sensor_name => $sensor_config) {
      $sensors_config[$sensor_name] = $sensor_config;
    }
  }
  else {
    foreach ($sensor_names as $sensor_name) {
      $sensors_config[$sensor_name] = monitoring_sensor_manager()
        ->getSensorConfigByName($sensor_name);
    }
  }

  /** @var \Drupal\Monitoring\SensorRunner $runner */
  $runner = \Drupal::service('monitoring.sensor_runner');
  $results = $runner
    ->runSensors($sensors_config, $force_run, $verbose);
  return $results;
}