You are here

nagios.install in Nagios Monitoring 7

Same filename and directory in other branches
  1. 5 nagios.install
  2. 6 nagios.install

Install, update and uninstall functions for the nagios module.

File

nagios.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the nagios module.
 *
 */

// Copyright 2009 Khalid Baheyeldin http://2bits.com

/**
 * Implements hook_uninstall().
 */
function nagios_uninstall() {
  variable_del('nagios_updates');
  variable_del('nagios_ua');
  variable_del('nagios_enable_status_page');
  variable_del('nagios_show_outdated_names');
  variable_del('nagios_status_ok_value');
  variable_del('nagios_status_warning_value');
  variable_del('nagios_status_critical_value');
  variable_del('nagios_status_unknown_value');
  variable_del('nagios_ignored_modules');
  variable_del('nagios_limit_watchdog_timestamp');
}

/**
 * Implements hook_requirements().
 */
function nagios_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {

    // Raise warning if Nagios Unique ID has not been set yet.
    if (variable_get('nagios_ua', '') == '') {
      $requirements['nagios'] = array(
        'title' => t('Nagios module'),
        'value' => t('Not configured'),
        'description' => t('Nagios module has not been configured yet. Please configure its settings from the <a href="@url">Nagios settings page</a>.', array(
          '@url' => url('admin/config/system/nagios'),
        )),
        'severity' => REQUIREMENT_WARNING,
      );
    }

    // Raise warning if core Update module is not enabled.
    if (!module_exists('update')) {
      $requirements['nagios'] = array(
        'title' => t('Nagios module'),
        'value' => t('Update module not enabled'),
        'description' => t('Update notifications are not enabled. Nagios cannot fully complete requirements checks without it. We recommend you enable the update manager module from the <a href="@url">module administration page</a>.', array(
          '@url' => url('admin/modules'),
        )),
        'severity' => REQUIREMENT_WARNING,
      );
    }
  }
  return $requirements;
}

/**
 * Set variable for altered status page path, if required.
 */
function nagios_update_7001() {
  if (variable_get('nagios_page_path', 'nagios') == 'nagios') {
    variable_set('nagios_page_path', 'nagios');
  }
}

/**
 * Rename variable for watchdog limit so it is clearly from this module.
 */
function nagios_update_7002() {
  variable_set('nagios_limit_watchdog_timestamp', variable_get('limit_watchdog_timestamp', FALSE));
  variable_del('limit_watchdog_timestamp');
}

Functions

Namesort descending Description
nagios_requirements Implements hook_requirements().
nagios_uninstall Implements hook_uninstall().
nagios_update_7001 Set variable for altered status page path, if required.
nagios_update_7002 Rename variable for watchdog limit so it is clearly from this module.