|
@@ -1,4 +1,91 @@
|
|
|
<?php
|
|
|
-function munin_api_help() {
|
|
|
+// $Id$
|
|
|
+/**
|
|
|
+ * @file
|
|
|
+ * An API to help modules expose their instrumentation to Munin.
|
|
|
+ */
|
|
|
+
|
|
|
+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();
|
|
|
+
|
|
|
+ $items['admin/reports/munin_api'] = array(
|
|
|
+ 'title' => 'Munin',
|
|
|
+ 'description' => 'Reports about Munin data collectors and their probes',
|
|
|
+ 'page callback' => 'munin_api_page_report_global',
|
|
|
+ 'access arguments' => array('access site reports'),
|
|
|
+ );
|
|
|
+
|
|
|
+ $items['admin/reports/munin_api/list'] = array(
|
|
|
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
|
|
|
+ 'title' => 'General',
|
|
|
+ );
|
|
|
+
|
|
|
+ $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'),
|
|
|
+ );
|
|
|
+
|
|
|
+ return $items;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Page callback for Munin report
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+function munin_api_page_report_global() {
|
|
|
+ $items = module_invoke_all('munin_api_info');
|
|
|
+
|
|
|
+ $header = array(
|
|
|
+ t('Module'),
|
|
|
+ t('Description'),
|
|
|
+ t('Stats'),
|
|
|
+ );
|
|
|
+ $rows = array();
|
|
|
+ foreach ($items as $name => $item) {
|
|
|
+ $link_title = $item['#title'] ? $item['#title'] : $name;
|
|
|
+ $rows[] = array(
|
|
|
+ l($link_title, 'admin/reports/munin_api/list/'. $name),
|
|
|
+ isset($item['#description']) ? $item['#description'] : t('<missing>'),
|
|
|
+ count(element_children($item)),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $ret = theme('table', $header, $rows);
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
+
|
|
|
+function munin_api_page_report_instance($module) {
|
|
|
+ $title = isset($module['#title']) ? $module['#title'] : t('Info');
|
|
|
+ drupal_set_title($title);
|
|
|
+
|
|
|
+ $header = array(t('Name'), t('Description'), t('Type'));
|
|
|
+ $rows = array();
|
|
|
+ foreach (element_children($module) as $name) {
|
|
|
+ $rows[] = array(
|
|
|
+ $name,
|
|
|
+ isset($module[$name]['#title']) ? $module[$name]['#title'] : t('<missing>'),
|
|
|
+ $module[$name]['#type'],
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $ret = theme('table', $header, $rows);
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
|
|
|
-}
|