From 1ec1ac396e8158886f302ac1b1fb20655e5f6b9f Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Fri, 28 Dec 2012 19:52:04 +0100 Subject: resolve php warning/notices when plugin doesn't exist For example when a non existing plugin is defined in $CONFIG['overview'] it causes a lot of php warnings/notices. --- inc/collectd.inc.php | 5 +++++ inc/html.inc.php | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'inc') diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index 3467667..99ffdd1 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php @@ -54,6 +54,7 @@ function collectd_plugindata($host, $plugin=NULL) { # only return data about one plugin if (!is_null($plugin)) { + $pdata = array(); foreach($data as $item) { if ($item['p'] == $plugin) $pdata[] = $item; @@ -113,6 +114,7 @@ function collectd_plugindetail($host, $plugin, $detail, $where=NULL) { function group_plugindata($plugindata) { global $CONFIG; + $data = array(); # type instances should be grouped in 1 graph foreach ($plugindata as $item) { # backwards compatibility @@ -129,6 +131,9 @@ function group_plugindata($plugindata) { } function plugin_sort($data) { + if (empty($data)) + return $data; + foreach ($data as $key => $row) { $pi[$key] = (isset($row['pi'])) ? $row['pi'] : null; $c[$key] = (isset($row['c'])) ? $row['c'] : null; diff --git a/inc/html.inc.php b/inc/html.inc.php index 20a10ed..3ad2439 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -58,10 +58,14 @@ EOT; } function plugin_header($host, $plugin) { + global $CONFIG; + return printf("

%s

\n", $CONFIG['weburl'], $host, $plugin, $plugin); } function plugins_list($host, $overview_plugins, $other_plugins, $selected_plugins = array()) { + global $CONFIG; + echo '
'; echo '

Plugins

'; echo '