|
@@ -9,6 +9,9 @@
|
|
|
* @copyright (c) 2011 Ouest Systèmes Informatiques
|
|
|
*
|
|
|
* Licensed under the General Public License version 2 or later.
|
|
|
+ *
|
|
|
+ * TODO Field name should be sanitized by "s/[^A-Za-z0-9_]/_/g"
|
|
|
+ * @link http://munin-monitoring.org/wiki/notes_on_datasource_names @endlink
|
|
|
*/
|
|
|
|
|
|
define('MUNIN_API_COUNTER', 'COUNTER');
|
|
@@ -132,6 +135,56 @@ function munin_api_menu() {
|
|
|
return $items;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements hook_munin_api_info().
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * An array of Munin probes informations, index by probe name.
|
|
|
+ */
|
|
|
+function munin_api_munin_api_info() {
|
|
|
+ $int = array(
|
|
|
+ '#graph_printf' => "'%d'",
|
|
|
+ );
|
|
|
+
|
|
|
+ $ret = array(
|
|
|
+ '#title' => t('Munin'),
|
|
|
+ '#description' => t('Munin monitoring'),
|
|
|
+
|
|
|
+ 'munin_munin' => array(
|
|
|
+ '#title' => t('Munin-node'),
|
|
|
+ '#info' => t('Monitor the monitoring solution.'),
|
|
|
+ '#graph_vlabel' => t('Seconds since last probe'),
|
|
|
+
|
|
|
+ 'munin_seconds' => $int + array(
|
|
|
+ '#label' => t('Seconds since last probe'),
|
|
|
+ '#type' => MUNIN_API_GAUGE,
|
|
|
+ '#info' => t('Seconds since last probe should hover around 300. 0 means no probe found.'),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Implements hook_munin_api_fetch().
|
|
|
+ */
|
|
|
+function munin_api_munin_api_fetch($graph_name, $log = TRUE) {
|
|
|
+ switch ($graph_name) {
|
|
|
+ case 'munin_munin':
|
|
|
+ $request_time = time();
|
|
|
+ $last = variable_get('munin_api_last', 0);
|
|
|
+ $ret['munin_seconds'] = $last ? $request_time - $last : 0;
|
|
|
+
|
|
|
+ if ($log) {
|
|
|
+ variable_set('munin_api_last', $request_time);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Page callback for munin config fetches.
|
|
|
*/
|
|
@@ -243,7 +296,7 @@ function munin_api_page_report_instance($module_name, $module_info) {
|
|
|
$error = array('class' => 'error');
|
|
|
$rows = array();
|
|
|
foreach (element_children($module_info) as $graph_name) {
|
|
|
- $data = module_invoke($module_name, 'munin_api_fetch', $graph_name);
|
|
|
+ $data = module_invoke($module_name, 'munin_api_fetch', $graph_name, FALSE);
|
|
|
if (!is_array($data)) {
|
|
|
return _munin_report_hook_error('munin_api_fetch', $module_name);
|
|
|
}
|