You are here

prod_check.install in Production check & Production monitor 6

Same filename and directory in other branches
  1. 7 prod_check.install

File

prod_check.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function prod_check_install() {

  // Allow immediate fetching of module data by prod_mon after installation
  // for remote the module status update checking feature.
  variable_set('prod_check_module_list_lastrun', -1);
}

/**
 * Implementation of hook_uninstall().
 */
function prod_check_uninstall() {

  // This beats multiple variable_del() calls.
  db_query("DELETE FROM {variable} WHERE name LIKE 'prod_check\\_%'");
}

/**
 * Implementation of hook_requirements().
 */
function prod_check_requirements($phase) {
  $requirements = array();
  switch ($phase) {
    case 'runtime':
      $sitemail = variable_get('prod_check_sitemail', '');
      if (empty($sitemail)) {
        $requirements['prod_check_email'] = array(
          'title' => t('Production check'),
          'value' => t('Site e-mail check not properly configured.'),
          'severity' => REQUIREMENT_WARNING,
          'description' => t('You have not changed the e-mail address on the prod-check !link. The Site e-mail check will not function properly. Please read the README.txt file.', prod_check_link_array('settings page', 'admin/settings/prod-check')),
        );
      }
      if (function_exists('apc_cache_info') && variable_get('prod_check_apcpass', 'password') == 'password') {
        $requirements['prod_check_apc_opc'] = array(
          'title' => t('Production check'),
          'value' => t('APC password not configured.'),
          'severity' => REQUIREMENT_WARNING,
          'description' => t('You have not !link for the APC status page. The page will function, but advanced options require that you set a password. Please read the README.txt file.', prod_check_link_array('changed the password', 'admin/settings/prod-check')),
        );
      }
      $nagios = variable_get('prod_check_enable_nagios', 0);
      if ($nagios && !module_exists('nagios')) {
        $requirements['prod_check_nagios'] = array(
          'title' => t('Production check'),
          'value' => t('Nagios module not installed/enabled.'),
          'severity' => REQUIREMENT_ERROR,
          'description' => t('You have enabled <em>Nagios integration</em> but you have not installed or enabled the !link module! Please install the !link module if you wish to use this functionality.', prod_check_link_array('Nagios', 'http://drupal.org/project/nagios')),
        );
      }
      break;
  }
  return $requirements;
}

/**
 * Update prod_check_nagios_checks if present.
 */
function prod_check_update_6100() {
  if ($checks = variable_get('prod_check_nagios_checks', FALSE)) {
    $prefix = '_prod_check_';
    foreach ($checks as $set => &$calls) {
      foreach ($calls as $key => &$function) {
        if (stripos($function, $prefix) === FALSE) {
          $function = $prefix . $function;
        }
      }
    }
    variable_set('prod_check_nagios_checks', $checks);
  }
  return array();
}

/**
 * Remove obsolete memcache settings.
 */
function prod_check_update_6101() {
  variable_del('prod_check_memcacheuser');
  variable_del('prod_check_memcachepass');
  return array();
}

Functions

Namesort descending Description
prod_check_install Implementation of hook_install().
prod_check_requirements Implementation of hook_requirements().
prod_check_uninstall Implementation of hook_uninstall().
prod_check_update_6100 Update prod_check_nagios_checks if present.
prod_check_update_6101 Remove obsolete memcache settings.