From 8e35bb446a9541060356b63ddebbd095648df22b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 2 Jun 2015 16:06:26 +0200 Subject: [PATCH] Hide columns with useless information in perfdata table Hide columns that don't provide any useful information, to reduce the size of the perfdata table. refs #8334 --- .../application/views/helpers/Perfdata.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 7b3fae266..5e17adea5 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -20,9 +20,10 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract { $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); $results = array(); + $keys = array('', 'label', 'value', 'min', 'max', 'warn', 'crit'); $columns = array(); $labels = array_combine( - array('', 'label', 'value', 'min', 'max', 'warn', 'crit'), + $keys, array( '', $this->view->translate('Label'), @@ -37,15 +38,23 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract if ($perfdata->isVisualizable()) { $columns[''] = ''; } - } - foreach ($pieChartData as $perfdata) { foreach ($perfdata->toArray() as $column => $value) { - if (! empty($value)) { - $columns[$column] = $labels[$column]; + if (empty($value) || + $column === 'min' && floatval($value) === 0.0 || + $column === 'max' && $perfdata->isPercentage() && floatval($value) === 100) { + continue; } + $columns[$column] = $labels[$column]; } } - $table = array('' . implode('', $columns) . ''); + // restore original column array sorting sorting + $headers = array(); + foreach ($keys as $i => $column) { + if (isset($columns[$column])) { + $headers[$column] = $labels[$column]; + } + } + $table = array('' . implode('', $headers) . ''); foreach ($pieChartData as $perfdata) { if ($compact && $perfdata->isVisualizable()) { $results[] = $perfdata->asInlinePie($color)->render();