Browse Source

Added munin_core module, simplified URLs

- new submodule to validate UI
- one local tab per submodule
- removed %munin_api_instance loader
FGM 13 years ago
parent
commit
b859e31c7a
3 changed files with 81 additions and 23 deletions
  1. 11 0
      modules/munin_core/munin_core.info
  2. 49 0
      modules/munin_core/munin_core.module
  3. 21 23
      munin_api.module

+ 11 - 0
modules/munin_core/munin_core.info

@@ -0,0 +1,11 @@
+; $Id$
+name = "Munin Core"
+description = "Core Drupal information collector for Munin"
+package = Administration
+
+core = 6.x
+
+project = "munin_api"
+datestamp = "1295949238"
+project status url = http://features.osinet.eu/fserver
+version = "6.x-1.x-dev"

+ 49 - 0
modules/munin_core/munin_core.module

@@ -0,0 +1,49 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Core Drupal instrumentation for Munin
+ */
+
+/**
+ * Implements hook_munin_api_info().
+ *
+ * @return
+ *   An array of Munin probes informations, index by probe name.
+ */
+function munin_core_munin_api_info() {
+  $ret = array(
+    'munin_core' => array(
+      '#title' => t('Drupal core'),
+      '#description' => t('Collect core information from a Drupal instance'),
+      'user_current' => array(
+        '#title'    => t('Currently logged-in users'),
+        '#type'     => MUNIN_API_GAUGE,
+      ),
+      'user_count' => array(
+        '#title'    => t('Number of users'),
+        '#type'     => MUNIN_API_COUNTER,
+      ),
+      'user_active_count' => array(
+        '#title'    => t('Number of active users'),
+        '#type'     => MUNIN_API_COUNTER,
+      ),
+      'user_blocked_count' => array(
+        '#title'    => t('Number of blocked users'),
+        '#type'     => MUNIN_API_COUNTER,
+      ),
+
+      'node_count' => array(
+        '#title'    => t('Number of nodes.'),
+        '#type'     => MUNIN_API_COUNTER,
+      ),
+
+      'comment_count' => array(
+        '#title'    => t('Number of comments.'),
+        '#type'     => MUNIN_API_COUNTER,
+      ),
+    ),
+  );
+
+  return $ret;
+}

+ 21 - 23
munin_api.module

@@ -5,22 +5,10 @@
  * An API to help modules expose their instrumentation to Munin.
  */
 
-define('MUNIN_API_COUNTER', 'counter');
-define('MUNIN_API_GAUGE', 'gauge');
+define('MUNIN_API_COUNTER', 'COUNTER');
+define('MUNIN_API_GAUGE',   'GAUGE');
 
 
-/**
- * Menu loader for %menu_api_instance.
- */
-function munin_api_instance_load($name) {
-  $module = module_invoke($name, 'munin_api_info');
-  $module = empty($module)
-    ? FALSE
-    : $module[$name];
-
-  return $module;
-}
-
 function munin_api_menu() {
   $items = array();
 
@@ -34,14 +22,21 @@ function munin_api_menu() {
   $items['admin/reports/munin_api/list'] = array(
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'title' => 'General',
+    'weight' => -1,
   );
 
-  $items['admin/reports/munin_api/list/%munin_api_instance'] = array(
-    'type' => MENU_CALLBACK,
-    'page callback' => 'munin_api_page_report_instance',
-    'page arguments' => array(4),
-    'access arguments' => array('access site reports'),
-  );
+  foreach (module_implements('munin_api_info') as $name) {
+    $module = module_invoke($name, 'munin_api_info');
+    $module = $module[$name];
+    $items['admin/reports/munin_api/'. $name] = array(
+      'type' => MENU_LOCAL_TASK,
+      'title' => $module['#title'],
+      'description' => $module['#description'],
+      'page callback' => 'munin_api_page_report_instance',
+      'page arguments' => array(3),
+      'access arguments' => array('access site reports'),
+    );
+  }
 
   return $items;
 }
@@ -63,7 +58,7 @@ function munin_api_page_report_global() {
   foreach ($items as $name => $item) {
     $link_title = $item['#title'] ? $item['#title'] : $name;
     $rows[] = array(
-      l($link_title, 'admin/reports/munin_api/list/'. $name),
+      l($link_title, 'admin/reports/munin_api/'. $name),
       isset($item['#description']) ? $item['#description'] : t('&lt;missing&gt;'),
       count(element_children($item)),
     );
@@ -73,8 +68,11 @@ function munin_api_page_report_global() {
 }
 
 function munin_api_page_report_instance($module) {
-  $title = isset($module['#title']) ? $module['#title'] : t('Info');
-  drupal_set_title($title);
+  dsm($module);
+  $module = module_invoke($module, 'munin_api_info');
+  $module = reset($module);
+  // $title = isset($module['#title']) ? $module['#title'] : t('Info');
+  // drupal_set_title($title);
 
   $header = array(t('Name'), t('Description'), t('Type'));
   $rows = array();