You are here

function nagios_check in Nagios Monitoring 6

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

Helper function for drush_nagios_check().

1 call to nagios_check()
drush_nagios_check in ./nagios.drush.inc
Drush command callback: nagios-check.

File

./nagios.drush.inc, line 63

Code

function nagios_check($module, $check) {
  $function = $module . '_nagios_check_' . $check;
  if (function_exists($function)) {
    $nagios_data = $function();
  }
  else {
    $function = $module . '_nagios_check';
    $nagios_data = $function($check);
  }
  $key = key($nagios_data);
  $status = nagios_status();
  $message = $key . ' ' . $status[$nagios_data[$key]['status']] . ' - ' . $nagios_data[$key]['text'];
  if ($nagios_data[$key]['type'] == 'perf') {
    $message .= '|' . $key . '=' . $nagios_data[$key]['text'];
  }

  // We want to exit with the correct exit status so Nagios knows the outcome
  // of our drush nagios check so set DRUSH_EXECUTION_COMPLETED to true.
  drush_set_context('DRUSH_EXECUTION_COMPLETED', TRUE);
  drush_print($message);
  exit((int) $nagios_data[$key]['status']);
}