public function MonitoringCommands::sensorConfigAll in Monitoring 8
List all sensors.
@validate-module-enabled monitoring
@command monitoring:list-sensors @aliases monitoring-list-sensors @field-labels label: Label name: Name category: Category enabled: Enabled description: Description value_info: Value info caching_time: Caching time has_thresholds: Has thresholds @default-fields label,name,category,enabled
Return value
\Consolidation\OutputFormatters\StructuredData\RowsOfFields A list with sensors.
File
- src/
Commands/ MonitoringCommands.php, line 90
Class
- MonitoringCommands
- A Drush commandfile for the Monitoring module.
Namespace
Drupal\monitoring\CommandsCode
public function sensorConfigAll() {
$sensor_config_list = $this->sensorManager
->getAllSensorConfig();
$rows = [];
foreach ($sensor_config_list as $name => $sensor_config) {
$rows[] = [
'label' => $sensor_config
->label(),
'name' => $name,
'category' => $sensor_config
->getCategory(),
'description' => $sensor_config
->getDescription(),
'value_info' => new FormattableMarkup('type: @type, label: @label, numeric: @numeric', [
'@type' => $sensor_config
->getValueType() ?: dt('N/A'),
'@label' => $sensor_config
->getValueLabel() ?: dt('N/A'),
'@numeric' => $sensor_config
->isNumeric() ? dt('Yes') : dt('No'),
]),
'caching_time' => $this->dateFormatter
->formatInterval($sensor_config
->getCachingTime()),
'enabled' => $sensor_config
->isEnabled() ? dt('Yes') : dt('No'),
'has_thresholds' => $sensor_config
->isDefiningThresholds() ? dt('Yes') : dt('No'),
];
}
return new RowsOfFields($rows);
}