You are here

function monitoring_drush_disable in Monitoring 8

Same name and namespace in other branches
  1. 7 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 445
Drush support for monitoring.

Code

function monitoring_drush_disable($sensor_name) {
  $sensor_manager = monitoring_sensor_manager();
  try {
    $sensor_config = $sensor_manager
      ->getSensorConfigByName($sensor_name);
    if ($sensor_config
      ->isEnabled()) {
      $sensor_manager
        ->disableSensor($sensor_name);
      drush_log(dt('The sensor @name was disabled.', array(
        '@name' => $sensor_config
          ->getLabel(),
      )), 'ok');
    }
    else {
      drush_log(dt('The sensor @name is already disabled.', array(
        '@name' => $sensor_config
          ->getLabel(),
      )), 'warning');
    }
  } catch (NonExistingSensorException $e) {
    drush_set_error('MONITORING_SENSOR_INVALID_NAME', dt('Sensor "@name" does not exist.', array(
      '@name' => $sensor_name,
    )));
  }
}