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
This commit is contained in:
parent
a5c3782de7
commit
8e35bb446a
|
@ -20,9 +20,10 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
|
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
|
||||||
$results = array();
|
$results = array();
|
||||||
|
$keys = array('', 'label', 'value', 'min', 'max', 'warn', 'crit');
|
||||||
$columns = array();
|
$columns = array();
|
||||||
$labels = array_combine(
|
$labels = array_combine(
|
||||||
array('', 'label', 'value', 'min', 'max', 'warn', 'crit'),
|
$keys,
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
$this->view->translate('Label'),
|
$this->view->translate('Label'),
|
||||||
|
@ -37,15 +38,23 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
if ($perfdata->isVisualizable()) {
|
if ($perfdata->isVisualizable()) {
|
||||||
$columns[''] = '';
|
$columns[''] = '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
foreach ($pieChartData as $perfdata) {
|
|
||||||
foreach ($perfdata->toArray() as $column => $value) {
|
foreach ($perfdata->toArray() as $column => $value) {
|
||||||
if (! empty($value)) {
|
if (empty($value) ||
|
||||||
|
$column === 'min' && floatval($value) === 0.0 ||
|
||||||
|
$column === 'max' && $perfdata->isPercentage() && floatval($value) === 100) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$columns[$column] = $labels[$column];
|
$columns[$column] = $labels[$column];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// restore original column array sorting sorting
|
||||||
|
$headers = array();
|
||||||
|
foreach ($keys as $i => $column) {
|
||||||
|
if (isset($columns[$column])) {
|
||||||
|
$headers[$column] = $labels[$column];
|
||||||
}
|
}
|
||||||
$table = array('<td><b>' . implode('</b></td><td><b>', $columns) . '<b></td>');
|
}
|
||||||
|
$table = array('<td><b>' . implode('</b></td><td><b>', $headers) . '<b></td>');
|
||||||
foreach ($pieChartData as $perfdata) {
|
foreach ($pieChartData as $perfdata) {
|
||||||
if ($compact && $perfdata->isVisualizable()) {
|
if ($compact && $perfdata->isVisualizable()) {
|
||||||
$results[] = $perfdata->asInlinePie($color)->render();
|
$results[] = $perfdata->asInlinePie($color)->render();
|
||||||
|
|
Loading…
Reference in New Issue