diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index db6f46f31..f077e9aae 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -146,6 +146,16 @@ class Perfdata return in_array($this->unit, array('s', 'ms', 'us')); } + /** + * Return whether this performance data's value is a temperature + * + * @return bool True in case it's temperature, otherwise False + */ + public function isTemperature() + { + return in_array($this->unit, array('°c', '°f')); + } + /** * Return whether this performance data's value is in percentage * @@ -287,7 +297,7 @@ class Perfdata $parts = explode(';', $this->perfdataValue); $matches = array(); - if (preg_match('@^(-?\d+(\.\d+)?)([a-zA-Z%]{1,2})$@', $parts[0], $matches)) { + if (preg_match('@^(-?\d+(\.\d+)?)([a-zA-Z%°]{1,2})$@u', $parts[0], $matches)) { $this->unit = strtolower($matches[3]); $this->value = self::convert($matches[1], $this->unit); } else { @@ -434,6 +444,9 @@ class Perfdata if ($this->isSeconds()) { return Format::seconds($value); } + if ($this->isTemperature()) { + return (string)$value . strtoupper($this->unit); + } return number_format($value, 2); }