You are here

function monitoring_drush_enable in Monitoring 7

Same name and namespace in other branches
  1. 8 monitoring.drush.inc \monitoring_drush_enable()

Drush callback to enable a sensor.

Parameters

string $sensor_name: Sensor name.

1 string reference to 'monitoring_drush_enable'
monitoring_drush_command in ./monitoring.drush.inc
Implements hook_drush_command().

File

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

Code

function monitoring_drush_enable($sensor_name) {
  $sensor_manager = monitoring_sensor_manager();
  try {
    $sensor_info = $sensor_manager
      ->getSensorInfoByName($sensor_name);
    if (!$sensor_info
      ->isEnabled()) {
      $sensor_manager
        ->enableSensor($sensor_name);
      drush_log(dt('The sensor @name was enabled.', array(
        '@name' => $sensor_info
          ->getLabel(),
      )), 'ok');
    }
    else {
      drush_log(dt('The sensor @name is already enabled.', array(
        '@name' => $sensor_info
          ->getLabel(),
      )), 'warning');
    }
  } catch (NonExistingSensorException $e) {
    drush_set_error('MONITORING_SENSOR_INVALID_NAME', dt('Sensor "@name" does not exist.', array(
      '@name' => $sensor_name,
    )));
  }
}