Browse Source

Requirements check: warn if Munin API is enabled but no pplugin submodule is enabled.

Frederic G. MARAND 13 years ago
parent
commit
ddc0dd84fa
3 changed files with 60 additions and 11 deletions
  1. 49 0
      modules/munin_apc/munin_apc.info
  2. 11 11
      munin_api.module
  3. 0 0
      plugins/munin-drupal_

+ 49 - 0
modules/munin_apc/munin_apc.info

@@ -0,0 +1,49 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Munin API for Drupal: installation and runtime checks.
+ *
+ * @author Frederic G. MARAND
+ *
+ * @copyright (c) 2011 Ouest Systèmes Informatiques
+ *
+ * Licensed under the General Public License version 2 or later.
+ */
+
+/**
+ * Implements hook_requirements().
+ */
+function munin_api_requirements($phase) {
+  $ret = array();
+  if ($phase == 'runtime') {
+    $count = count(module_implements('munin_api_info'));
+    if ($count == 0) {
+      $req = array(
+        'title' => t('Munin plugin modules'),
+        'value' => t('No Munin plugin module enabled'),
+        'description' => t('Munin API is enabled, but no plugin module is enabled to report to it. In this situation, Munin API consumes resources but does not actually report anything. You should either enable some plugin modules or disable and uninstall Munin API.'),
+        'severity' => REQUIREMENT_WARNING,
+      );
+    }
+    else {
+      $req = array(
+        'title' => t('Munin plugin modules'),
+        'value' => format_plural($count, '1 Munin plugin enabled.',
+          '@count Munin plugins enabled.'),
+        'severity' => REQUIREMENT_OK,
+      );
+    }
+    $ret[] = $req;
+  }
+  elseif ($phase != 'install') {
+    // This should never happen and points to a severe error somewhere
+    watchdog('munin_api', 'Invalid phase %phase passed to %function', array(
+      '%phase' => $phase,
+      '%function' => __FUNCTION__,
+    ), WATCHDOG_ERROR);
+  }
+  // else $phase == 'install', nothing to do.
+
+  return $ret;
+}

+ 11 - 11
munin_api.module

@@ -11,23 +11,23 @@
  * Licensed under the General Public License version 2 or later.
  */
 
-define('MUNIN_API_COUNTER',  'COUNTER');
-define('MUNIN_API_DERIVE',   'DERIVE');
-define('MUNIN_API_GAUGE',    'GAUGE');
-define('MUNIN_API_ABSOLUTE', 'ABSOLUTE'); // Counters reset upon reading (uncommon)
+define('MUNIN_API_COUNTER',          'COUNTER');
+define('MUNIN_API_DERIVE',           'DERIVE');
+define('MUNIN_API_GAUGE',            'GAUGE');
+define('MUNIN_API_ABSOLUTE',         'ABSOLUTE'); // Counters reset upon reading (uncommon)
 
-define('MUNIN_API_DRAW_AREA',		'AREA');
-define('MUNIN_API_DRAW_LINE0',  'LINE0'); // Invisible line, but triggers graphs scaling
-define('MUNIN_API_DRAW_LINE1',  'LINE1'); // Default on Munin 2.0
-define('MUNIN_API_DRAW_LINE2',  'LINE2'); // Default on Munine < 2.0
-define('MUNIN_API_DRAW_LINE3',	'LINE3');
-define('MUNIN_API_DRAW_STACK',  'STACK');
+define('MUNIN_API_DRAW_AREA',        'AREA');
+define('MUNIN_API_DRAW_LINE0',       'LINE0'); // Invisible line, but triggers graphs scaling
+define('MUNIN_API_DRAW_LINE1',       'LINE1'); // Default on Munin 2.0
+define('MUNIN_API_DRAW_LINE2',       'LINE2'); // Default on Munin < 2.0
+define('MUNIN_API_DRAW_LINE3',       'LINE3');
+define('MUNIN_API_DRAW_STACK',       'STACK');
 
 // Styles below are only supported on Munin >= 1.3.3
 define('MUNIN_API_DRAW_LINESTACK1',  'LINESTACK1');
 define('MUNIN_API_DRAW_LINESTACK2',  'LINESTACK2');
 define('MUNIN_API_DRAW_LINESTACK3',  'LINESTACK3');
-define('MUNIN_API_DRAW_AREASTACK',  	'AREASTACK');
+define('MUNIN_API_DRAW_AREASTACK',   'AREASTACK');
 
 /**
  * Finalize result pages for Munin interactions.

+ 0 - 0
plugins/munin-drupal_