You are here

function monitoring_drush_command in Monitoring 8

Same name and namespace in other branches
  1. 7 monitoring.drush.inc \monitoring_drush_command()

Implements hook_drush_command().

Provides commands:

  • monitoring-sensor-config
  • monitoring-run
  • monitoring-enable
  • monitoring-disable

File

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

Code

function monitoring_drush_command() {
  $items = array();
  $items['monitoring-sensor-config'] = array(
    'callback' => 'monitoring_drush_sensor_config',
    'description' => 'Displays information about available sensors. If a sensor name provided as argument a detailed sensor config is provided.',
    'arguments' => array(
      'sensor_name' => 'Specific sensor name for which we want to display info.',
    ),
    'examples' => array(
      'drush monitoring-sensor-config' => 'Prints sensor config for all available sensors.',
      'drush monitoring-sensor-config node_new' => 'Prints info of the node_new sensor.',
    ),
    'drupal dependencies' => array(
      'monitoring',
    ),
  );
  $items['monitoring-run'] = array(
    'callback' => 'monitoring_drush_run',
    'description' => 'Runs specific sensor and provides verbose data.',
    'arguments' => array(
      'sensor_name' => 'Sensor name to invoke.',
    ),
    'options' => array(
      'verbose' => 'Display verbose information.',
      'force' => 'If the sensor execution should be forced in case cached result is available.',
      'output' => 'The output format. Currently "table", "json" and "sensu" available. Defaults to "table".',
      'expand' => 'Relevant only for the json output. Currently "sensor" value supported.',
      'show-exec-time' => 'Relevant for the table output listing all results. Will expand the table with execution time info.',
      'sensu-source' => 'Relevant only for sensu output. The sensu source. Defaults to the host name.',
      'sensu-ttl' => 'Relevant only for sensu output. Sensu TTL (Time to live)',
      'sensu-handlers' => 'Relevant only for sensu output. A comma separated list of Sensu handlers (names).',
      'sensu-metric-handlers' => 'Relevant only for sensu output. Defaults to the Sensu handlers.',
      'sensu-metrics' => 'Relevant only for sensu output. Expose numeric sensors additionally as metrics. Enabled by default.',
    ),
    'examples' => array(
      'drush monitoring-run monitoring_git_dirty_tree' => 'Runs sensor to monitor the git status.',
      'drush monitoring-run --verbose monitoring_git_dirty_tree' => 'Runs sensor to monitor the git status and displays verbose information.',
      'drush monitoring-run --output=json --watchdog=disable' => 'Will output the sensor results in json format. The option --watchdog=disable will suppress watchdog output to console.',
      'drush monitoring-run --output=sensu --sensu-source=example.org --sensu-ttl=600 --sensu-handlers=email,pagerduty' => 'Will output the sensor results in sensu format. The option --sensu-source=example.org will provide the sensu source. The option --sensu-ttl=600 will provide the sensor 600 seconds time to live.',
    ),
    'drupal dependencies' => array(
      'monitoring',
    ),
  );
  $items['monitoring-enable'] = array(
    'callback' => 'monitoring_drush_enable',
    'description' => 'Enable specified monitoring sensor.',
    'arguments' => array(
      'sensor_name' => 'Sensor name to enable.',
    ),
    'required-arguments' => TRUE,
    'examples' => array(
      'drush monitoring-enable monitoring_git_dirty_tree' => 'Enables monitoring_git_dirty_tree sensor.',
    ),
    'drupal dependencies' => array(
      'monitoring',
    ),
  );
  $items['monitoring-disable'] = array(
    'callback' => 'monitoring_drush_disable',
    'description' => 'Disable specified monitoring sensor.',
    'arguments' => array(
      'sensor_name' => 'Sensor name to disable.',
    ),
    'required-arguments' => TRUE,
    'examples' => array(
      'drush monitoring-disable monitoring_git_dirty_tree' => 'Disables monitoring_git_dirty_tree sensor.',
    ),
    'drupal dependencies' => array(
      'monitoring',
    ),
  );
  $items['monitoring-rebuild'] = [
    'callback' => 'monitoring_drush_rebuild',
    'description' => 'Rebuild the list of sensors',
    'drupal dependencies' => [
      'monitoring',
    ],
  ];
  return $items;
}