diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php
index 47c34d156..dd451bc1a 100644
--- a/modules/monitoring/application/views/helpers/Perfdata.php
+++ b/modules/monitoring/application/views/helpers/Perfdata.php
@@ -24,21 +24,36 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
$result = '';
- $table = array();
+ $table = array(
+ '
' . implode(
+ ' | ',
+ array('', t('Label'), t('Value'), t('Min'), t('Max'), t('Warning'), t('Critical'))
+ ) . ' | '
+ );
foreach ($pieChartData as $perfdata) {
- if ($perfdata->isVisualizable()) {
- $pieChart = $perfdata->asInlinePie($color);
- if ($compact) {
- $result .= $pieChart->render();
- } else {
- $table[] = '' . $pieChart->render()
- . htmlspecialchars($perfdata->getLabel())
- . ' | '
- . htmlspecialchars($this->formatPerfdataValue($perfdata)) .
- ' |
';
- }
+
+ if ($compact && $perfdata->isVisualizable()) {
+ $result .= $perfdata->asInlinePie($color)->render();
} else {
- $table[] = (string)$perfdata;
+ $row = '';
+
+ $row .= '';
+ if ($perfdata->isVisualizable()) {
+ $row .= $perfdata->asInlinePie($color)->render() . ' ';
+ }
+ $row .= ' | ';
+
+ if (!$compact) {
+ foreach ($perfdata->toArray() as $value) {
+ if ($value === '') {
+ $value = '-';
+ }
+ $row .= '' . (string)$value . ' | ';
+ }
+ }
+
+ $row .= '
';
+ $table[] = $row;
}
}
@@ -49,18 +64,4 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
return $pieCharts;
}
}
-
- protected function formatPerfdataValue(Perfdata $perfdata)
- {
- if ($perfdata->isBytes()) {
- return Format::bytes($perfdata->getValue());
- } elseif ($perfdata->isSeconds()) {
- return Format::seconds($perfdata->getValue());
- } elseif ($perfdata->isPercentage()) {
- return $perfdata->getValue() . '%';
- }
-
- return $perfdata->getValue();
- }
-
}
diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php
index 7da4559fd..3e0237184 100644
--- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php
+++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Monitoring\Plugin;
+use Icinga\Util\Format;
use InvalidArgumentException;
use Icinga\Exception\ProgrammingError;
use Icinga\Web\Widget\Chart\InlinePie;
@@ -263,7 +264,7 @@ class Perfdata
*/
public function __toString()
{
- return sprintf(strpos($this->label, ' ') === false ? '%s=%s' : "'%s'=%s", $this->label, $this->perfdataValue);
+ return $this->formatLabel();
}
/**
@@ -294,11 +295,9 @@ class Perfdata
$this->minValue = self::convert($parts[3], $this->unit);
}
case 3:
- // TODO(#6123): Tresholds have the same UOM and need to be converted as well!
- $this->criticalThreshold = trim($parts[2]) ? trim($parts[2]) : null;
+ $this->criticalThreshold = trim($parts[2]) ? self::convert(trim($parts[2]), $this->unit) : null;
case 2:
- // TODO(#6123): Tresholds have the same UOM and need to be converted as well!
- $this->warningThreshold = trim($parts[1]) ? trim($parts[1]) : null;
+ $this->warningThreshold = trim($parts[1]) ? self::convert(trim($parts[1]), $this->unit) : null;
}
}
@@ -370,7 +369,7 @@ class Perfdata
}
$data = $this->calculatePieChartData($color);
- $pieChart = new InlinePie($data, $this->getLabel() . ' ' . number_format($this->getPercentage(), 2) . '%');
+ $pieChart = new InlinePie($data, $this);
$pieChart->setSparklineClass('sparkline-perfdata');
if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) {
@@ -378,4 +377,51 @@ class Perfdata
}
return $pieChart;
}
+
+ /**
+ * Format the given value depending on the currently used unit
+ */
+ protected function format($value)
+ {
+ if ($this->isPercentage()) {
+ return (string)$value . '%';
+ }
+ if ($this->isBytes()) {
+ return Format::bytes($value);
+ }
+ if ($this->isSeconds()) {
+ return Format::seconds($value);
+ }
+ return number_format($value, 2);
+ }
+
+ /**
+ * Format the title string that represents this perfdata set
+ *
+ * @param bool $html
+ *
+ * @return stringS
+ */
+ public function formatLabel($html = false)
+ {
+ return sprintf(
+ $html ? t('%s %s (%s%%)') : t('%s %s (%s%%)'),
+ htmlspecialchars($this->getLabel()),
+ $this->format($this->value),
+ number_format($this->getPercentage(), 2)
+ );
+ }
+
+ public function toArray()
+ {
+ $parts = array(
+ $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) : '',
+ 'warn' => isset($this->warningThreshold) ? $this->format($this->warningThreshold) : '',
+ 'crit' => isset($this->criticalThreshold) ? $this->format($this->criticalThreshold) : ''
+ );
+ return $parts;
+ }
}
diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less
index 6972e95dc..5b142184d 100644
--- a/public/css/icinga/main-content.less
+++ b/public/css/icinga/main-content.less
@@ -154,6 +154,7 @@ table.perfdata th {
table.perfdata td {
white-space: nowrap;
+ padding-right: 0.5em;
}
table.objectlist {