From 60fb79ac97869b8333621380828dd1b84a069990 Mon Sep 17 00:00:00 2001 From: Rohit Bhute Date: Sun, 17 Mar 2013 13:40:38 +0530 Subject: add feature to show a subset of graphs from a plugin on overview page --- conf/config.php | 2 ++ host.php | 4 +++- inc/collectd.inc.php | 13 ++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/conf/config.php b/conf/config.php index b2fdc78..6755582 100644 --- a/conf/config.php +++ b/conf/config.php @@ -18,6 +18,8 @@ $CONFIG['rrdtool_opts'] = ''; # default plugins to show on host page $CONFIG['overview'] = array('load', 'cpu', 'memory', 'swap'); +$CONFIG['overview_filter']['interface'] = array('ti' => 'eth0', 't' => 'if_octets'); + # default plugins time range $CONFIG['time_range']['default'] = 86400; $CONFIG['time_range']['uptime'] = 31536000; diff --git a/host.php b/host.php index 71d786a..363e9d5 100644 --- a/host.php +++ b/host.php @@ -22,11 +22,13 @@ if(!$plugins) { plugins_list($host, $selected_plugins); +$overview = empty($plugin) ? true : false; + echo '
'; foreach ($selected_plugins as $selected_plugin) { if (in_array($selected_plugin, $plugins)) { plugin_header($host, $selected_plugin); - graphs_from_plugin($host, $selected_plugin); + graphs_from_plugin($host, $selected_plugin, $overview); } } echo '
'; diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index 56c5a2d..e8f3662 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php @@ -147,14 +147,25 @@ function plugin_sort($data) { } # generate graph url's for a plugin of a host -function graphs_from_plugin($host, $plugin) { +function graphs_from_plugin($host, $plugin, $overview=false) { global $CONFIG; $plugindata = collectd_plugindata($host, $plugin); $plugindata = group_plugindata($plugindata); $plugindata = plugin_sort($plugindata); + $f = array(); + + if ($overview == true && isset($CONFIG['overview_filter'][$plugin])) { + $f = $CONFIG['overview_filter'][$plugin]; + } + foreach ($plugindata as $items) { + + if (!empty($f) && ($f !== array_intersect_assoc($f, $items))) { + continue; + } + $items['h'] = $host; $time = array_key_exists($plugin, $CONFIG['time_range']) -- cgit v1.1