You are here

function drush_nagios_check in Nagios Monitoring 7

Same name and namespace in other branches
  1. 8 nagios.drush.inc \drush_nagios_check()
  2. 6 nagios.drush.inc \drush_nagios_check()

Drush command callback: nagios-check.

File

./nagios.drush.inc, line 48
Provides drush integration for the Nagios module.

Code

function drush_nagios_check($check = NULL) {
  if (isset($check)) {
    foreach (module_implements('nagios_checks') as $module) {
      if (array_key_exists($check, module_invoke($module, 'nagios_checks'))) {
        nagios_check($module, $check);
        return;
      }
    }
    foreach (drush_command_implements('nagios_checks') as $command) {

      /** @var callable $function */
      $function = $command . '_nagios_checks';
      if (array_key_exists($check, $function())) {
        nagios_check($command, $check);
        return;
      }
    }
    drush_set_error(dt('The requested nagios check does not exist: !check.', [
      '!check' => $check,
    ]));
  }
  else {
    drush_set_error(dt('Missing argument for nagios-check'));
  }
  drush_set_error(dt('Run `drush nagios-list` for valid checks.'));
}