From 1ad4de5b08e5d9fde394380418dda6f909ff91b4 Mon Sep 17 00:00:00 2001
From: Pim van den Berg
Date: Sat, 30 Mar 2013 14:08:23 +0100
Subject: rewrite some code of added overview_filter feature
Use less variables, less code.
---
host.php | 4 +---
inc/collectd.inc.php | 11 ++++-------
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/host.php b/host.php
index 363e9d5..453cfb4 100644
--- a/host.php
+++ b/host.php
@@ -22,13 +22,11 @@ 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, $overview);
+ graphs_from_plugin($host, $selected_plugin, empty($plugin));
}
}
echo '
';
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php
index e8f3662..ad15774 100644
--- a/inc/collectd.inc.php
+++ b/inc/collectd.inc.php
@@ -154,15 +154,12 @@ function graphs_from_plugin($host, $plugin, $overview=false) {
$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))) {
+ if (
+ $overview && isset($CONFIG['overview_filter'][$plugin]) &&
+ $CONFIG['overview_filter'][$plugin] !== array_intersect_assoc($CONFIG['overview_filter'][$plugin], $items)
+ ) {
continue;
}
--
cgit v1.1