diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 36cbaa319..7b3fae266 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -20,44 +20,51 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract { $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); $results = array(); - $table = array( - '' . implode( - '', - array( - '', - $this->view->translate('Label'), - $this->view->translate('Value'), - $this->view->translate('Min'), - $this->view->translate('Max'), - $this->view->translate('Warning'), - $this->view->translate('Critical') - ) - ) . '' + $columns = array(); + $labels = array_combine( + array('', 'label', 'value', 'min', 'max', 'warn', 'crit'), + array( + '', + $this->view->translate('Label'), + $this->view->translate('Value'), + $this->view->translate('Min'), + $this->view->translate('Max'), + $this->view->translate('Warning'), + $this->view->translate('Critical') + ) ); foreach ($pieChartData as $perfdata) { - + if ($perfdata->isVisualizable()) { + $columns[''] = ''; + } + } + foreach ($pieChartData as $perfdata) { + foreach ($perfdata->toArray() as $column => $value) { + if (! empty($value)) { + $columns[$column] = $labels[$column]; + } + } + } + $table = array('' . implode('', $columns) . ''); + foreach ($pieChartData as $perfdata) { if ($compact && $perfdata->isVisualizable()) { $results[] = $perfdata->asInlinePie($color)->render(); } else { - $row = ''; - - $row .= ''; + $data = array(); if ($perfdata->isVisualizable()) { - $row .= $perfdata->asInlinePie($color)->render() . ' '; + $data []= $perfdata->asInlinePie($color)->render() . ' '; + } else if (isset($columns[''])) { + $data []= ''; } - $row .= ''; - if (! $compact) { - foreach ($perfdata->toArray() as $value) { - if ($value === '') { - $value = '-'; + foreach ($perfdata->toArray() as $column => $value) { + if (! isset($columns[$column])) { + continue; } - $row .= '' . (string) $value . ''; + $data []= empty($value) ? '-' : (string) $value; } } - - $row .= ''; - $table[] = $row; + $table []= '' . implode('', $data) . ''; } } if ($limit > 0) { diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index b1c71cb72..df1b6016a 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -444,7 +444,7 @@ class Perfdata public function toArray() { $parts = array( - $this->getLabel(), + 'label' => $this->getLabel(), 'value' => $this->format($this->getvalue()), 'min' => isset($this->minValue) && !$this->isPercentage() ? $this->format($this->minValue) : '', 'max' => isset($this->maxValue) && !$this->isPercentage() ? $this->format($this->maxValue) : '',