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 +++++ 1 file changed, 5 insertions(+) (limited to 'inc/collectd.inc.php') 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; -- cgit v1.1