function monitoring_sensor_run_multiple in Monitoring 7
Same name and namespace in other branches
- 8 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
4 calls to monitoring_sensor_run_multiple()
- monitoring_drush_run in ./
monitoring.drush.inc - Drush callback to get sensor results.
- monitoring_icinga_drush_callback in modules/
monitoring_icinga/ monitoring_icinga.drush.inc - Drush callback to get the sensor info.
- monitoring_sensor_run in ./
monitoring.module - The sensor runner function.
- monitoring_services_sensors_results in ./
monitoring.services.inc - Sensor result resource.
File
- ./
monitoring.module, line 122 - Monitoring bootstrap file.
Code
function monitoring_sensor_run_multiple($sensor_names = array(), $force_run = FALSE, $verbose = FALSE) {
$sensors_info = array();
if (empty($sensor_names)) {
foreach (monitoring_sensor_manager()
->getEnabledSensorInfo() as $sensor_name => $sensor_info) {
$sensors_info[$sensor_name] = $sensor_info;
}
}
else {
foreach ($sensor_names as $sensor_name) {
$sensors_info[$sensor_name] = monitoring_sensor_manager()
->getSensorInfoByName($sensor_name);
}
}
$runner = new SensorRunner($sensors_info);
$runner
->verbose($verbose);
$runner
->forceRun($force_run);
$results = $runner
->runSensors();
return $results;
}