You are here

function drush_nagios_check in Nagios Monitoring 8

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

Drush command callback: nagios-check.

Parameters

null|string $check: Function name to execute.

File

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

Code

function drush_nagios_check($check = NULL) {
  $moduleHandler = \Drupal::service('module_handler');
  if ($check !== NULL) {
    foreach ($moduleHandler
      ->getImplementations('nagios_checks') as $module) {
      if (array_key_exists($check, $moduleHandler
        ->invoke($module, 'nagios_checks'))) {
        nagios_check($module, $check);
        return;
      }
    }
    foreach (drush_command_implements('nagios_checks') as $command) {
      $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'));
  }
}