You are here

function monitoring_drush_disable in Monitoring 7

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

Drush callback to disable a sensor.

Parameters

string $sensor_name: Sensor name.

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

File

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

Code

function monitoring_drush_disable($sensor_name) {
  $sensor_manager = monitoring_sensor_manager();
  try {
    $sensor_info = $sensor_manager
      ->getSensorInfoByName($sensor_name);
    if ($sensor_info
      ->isEnabled()) {
      $sensor_manager
        ->disableSensor($sensor_name);
      drush_log(dt('The sensor @name was disabled.', array(
        '@name' => $sensor_info
          ->getLabel(),
      )), 'ok');
    }
    else {
      drush_log(dt('The sensor @name is already disabled.', 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,
    )));
  }
}