You are here

function nagios_check_requirements in Nagios Monitoring 5

Same name and namespace in other branches
  1. 8 nagios.module \nagios_check_requirements()
  2. 6 nagios.module \nagios_check_requirements()
  3. 7 nagios.module \nagios_check_requirements()

File

./nagios.module, line 272

Code

function nagios_check_requirements() {

  // Load .install files
  include_once './includes/install.inc';
  drupal_load_updates();

  // Get the run-time requirements and status information.
  $reqs = module_invoke_all('requirements', 'runtime');

  // Check the requirements as to the most severe status
  $severity = REQUIREMENT_OK;
  foreach ($reqs as $key => $requirement) {
    if (isset($requirement['severity'])) {
      if ($requirement['severity'] > $severity) {
        $severity = $requirement['severity'];
        $desc = $requirement['title'];
      }
    }
  }

  // Create a status to pass back, and a text description too
  switch ($severity) {
    case REQUIREMENT_OK:
    case REQUIREMENT_INFO:
      $data = array(
        'status' => NAGIOS_STATUS_OK,
        'type' => 'state',
        'text' => '',
      );
      break;
    case REQUIREMENT_WARNING:
      $data = array(
        'status' => NAGIOS_STATUS_WARNING,
        'type' => 'state',
        'text' => t('@desc', array(
          '@desc' => $desc,
        )),
      );
      break;
    case REQUIREMENT_ERROR:
      $data = array(
        'status' => NAGIOS_STATUS_CRITICAL,
        'type' => 'state',
        'text' => t('@desc', array(
          '@desc' => $desc,
        )),
      );
      break;
    default:
      $data = array(
        'status' => NAGIOS_STATUS_UNKNOWN,
        'type' => 'state',
        'text' => t('severity is @severity', array(
          '@severity' => $severity,
        )),
      );
      break;
  }
  return array(
    'key' => 'ADMIN',
    'data' => $data,
  );
}