You are here

monitoring_icinga.module in Monitoring 7

Monitoring Nagios module bootstrap file.

File

modules/monitoring_icinga/monitoring_icinga.module
View source
<?php

/**
 * @file
 * Monitoring Nagios module bootstrap file.
 */
use Drupal\monitoring\Result\SensorResultInterface;
use Drupal\monitoring\Sensor\SensorInfo;
use Drupal\monitoring\SensorRunner;

/**
 * Implements hook_menu().
 */
function monitoring_icinga_menu() {
  $items['admin/config/system/monitoring/icinga'] = array(
    'title' => 'Icinga',
    'description' => 'Configure Nagios/Icinga connector',
    'page callback' => 'monitoring_icinga_config_active_page',
    'access arguments' => array(
      'administer monitoring',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'monitoring_icinga.admin.inc',
  );
  $items['admin/config/system/monitoring/icinga/active'] = array(
    'title' => 'Active check',
    'description' => 'Configure Nagios/Icinga connector for active checks',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'file' => 'monitoring_icinga.admin.inc',
  );
  $items['admin/config/system/monitoring/icinga/passive'] = array(
    'title' => 'Passive check',
    'description' => 'Configure Nagios/Icinga connector for passive checks',
    'page callback' => 'monitoring_icinga_config_passive_page',
    'access arguments' => array(
      'administer monitoring',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'monitoring_icinga.admin.inc',
  );
  $items['admin/config/system/monitoring/icinga/passive-with-freshness'] = array(
    'title' => 'Passive check /w freshness',
    'description' => 'Configure Nagios/Icinga connector for passive checks with freshness check',
    'page callback' => 'monitoring_icinga_config_passive_with_freshness_page',
    'access arguments' => array(
      'administer monitoring',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'monitoring_icinga.admin.inc',
  );
  return $items;
}

/**
 * Gets service description for Icinga.
 *
 * This is vital for matching the generated service (sensor) config and
 * submitting passive check.
 *
 * @param SensorInfo $sensor_info
 *   Sensor info object.
 *
 * @return string
 *   Icinga service description.
 */
function monitoring_icinga_service_description(SensorInfo $sensor_info) {
  return $sensor_info
    ->getCategory() . ' - ' . $sensor_info
    ->getLabel() . ' - ' . $sensor_info
    ->getName();
}

/**
 * Get icinga status mappings.
 *
 * @return array
 *   Mapped statuses.
 */
function monitoring_icinga_status_codes() {
  return array(
    'OK' => 0,
    'WARNING' => 1,
    'CRITICAL' => 2,
    'UNKNOWN' => 3,
  );
}

Functions

Namesort descending Description
monitoring_icinga_menu Implements hook_menu().
monitoring_icinga_service_description Gets service description for Icinga.
monitoring_icinga_status_codes Get icinga status mappings.