You are here

function monitoring_drush_sensor_config_single in Monitoring 8

Prints detailed info about the given sensor $sensor_name.

Parameters

string $sensor_name: Sensor name for which to print info.

1 call to monitoring_drush_sensor_config_single()
monitoring_drush_sensor_config in ./monitoring.drush.inc
Drush callback to get available sensors info.

File

./monitoring.drush.inc, line 162
Drush support for monitoring.

Code

function monitoring_drush_sensor_config_single($sensor_name) {
  $sensor_config = NULL;
  try {
    $sensor_config = monitoring_sensor_manager()
      ->getSensorConfigByName($sensor_name);
  } catch (NonExistingSensorException $e) {
    return drush_set_error('MONITORING_SENSOR_INVALID_NAME', dt('Sensor "@name" does not exist.', array(
      '@name' => $sensor_name,
    )));
  }
  $rows[] = array(
    new FormattableMarkup("@label (@id)", array(
      '@label' => $sensor_config
        ->getLabel(),
      '@id' => $sensor_config
        ->id(),
    )),
    '====================',
  );
  $rows[] = array(
    dt('Category'),
    $sensor_config
      ->getCategory(),
  );
  $rows[] = array(
    dt('Description'),
    $sensor_config
      ->getDescription(),
  );
  $rows[] = array(
    dt('Value info'),
    new FormattableMarkup('type: @type, label: @label, numeric: @numeric', array(
      '@type' => $sensor_config
        ->getValueType() ? $sensor_config
        ->getValueType() : dt('N/A'),
      '@label' => $sensor_config
        ->getValueLabel() ? $sensor_config
        ->getValueLabel() : dt('N/A'),
      '@numeric' => $sensor_config
        ->isNumeric() ? dt('Yes') : dt('No'),
    )),
  );
  $rows[] = array(
    dt('Caching time'),
    \Drupal::service('date.formatter')
      ->formatInterval($sensor_config
      ->getCachingTime()),
  );
  $rows[] = array(
    dt('Enabled'),
    $sensor_config
      ->isEnabled() ? dt('Yes') : dt('No'),
  );
  $rows[] = array(
    dt('Has thresholds'),
    $sensor_config
      ->isDefiningThresholds() ? dt('Yes') : dt('No'),
  );
  drush_print_table($rows);
}