You are here

function performance_requirements in Performance Logging and Monitoring 7.2

Same name and namespace in other branches
  1. 6.2 performance.install \performance_requirements()
  2. 6 performance.install \performance_requirements()
  3. 7 performance.install \performance_requirements()

Implements hook_requirements().

File

./performance.install, line 158
Install and update for Performance Logging

Code

function performance_requirements($phase) {
  $requirements = array();
  if ($phase != 'runtime') {
    return $requirements;
  }
  if (variable_get('performance_detail', 0)) {
    $requirements['performance_detail'] = array(
      'title' => t('Performance logging details'),
      'value' => 'Enabled',
      'severity' => REQUIREMENT_WARNING,
      'description' => t('Performance detailed logging is !link. This can cause severe issues on live sites.', array(
        '!link' => l(t('enabled'), PERFORMANCE_SETTINGS),
      )),
    );
  }
  if (variable_get(PERFORMANCE_QUERY_VAR, 0)) {
    if (variable_get('performance_detail', 0) || variable_get('performance_summary', 0)) {
      $requirements['performance_query'] = array(
        'title' => t('Performance logging query'),
        'value' => 'Enabled',
        'severity' => REQUIREMENT_WARNING,
        'description' => t('Query timing and count logging is !link. This can cause memory size per page to be larger than normal.', array(
          '!link' => l(t('enabled'), PERFORMANCE_SETTINGS),
        )),
      );
    }
  }
  $default = 'DrupalDatabaseCache';
  $cache = variable_get(PERFORMANCE_CACHE, $default);
  if ($cache == $default) {
    $requirements['performance_cache'] = array(
      'title' => t('Performance logging summary'),
      'value' => 'Disabled',
      'severity' => REQUIREMENT_WARNING,
      'description' => t('Performance logging on live web sites works best if an alternative caching mechanism, like APC or Memcache, is enabled.'),
    );
  }
  $shm_size = ini_get('apc.shm_size');
  if (function_exists('apc_fetch') && $shm_size < PERFORMANCE_MIN_MEMORY) {
    $requirements['performance_apc_mem'] = array(
      'title' => t('Performance logging APC memory size'),
      'value' => $shm_size,
      'severity' => REQUIREMENT_WARNING,
      'description' => t('APC has been configured for !size, which is less than the recommended !min_memory MB of memory. If you encounter errors when viewing the summary report, then try to increase that limit for APC.', array(
        '!size' => 1 * $shm_size,
        '!min_memory' => PERFORMANCE_MIN_MEMORY,
      )),
    );
  }
  return $requirements;
}