diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index 34a63c787..bafb49f49 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -307,8 +307,8 @@ class Perfdata $parts = explode(';', $this->perfdataValue); $matches = array(); - if (preg_match('@^(-?\d+(\.\d+)?)([a-zA-Z%°]{1,2})$@u', $parts[0], $matches)) { - $this->unit = strtolower($matches[3]); + if (preg_match('@^(-?(?:\d+)?(?:\.\d+)?)([a-zA-Z%°]{1,3})$@u', $parts[0], $matches)) { + $this->unit = strtolower($matches[2]); $this->value = self::convert($matches[1], $this->unit); } else { $this->value = self::convert($parts[0]); @@ -458,7 +458,7 @@ class Perfdata if ($this->isTemperature()) { return (string)$value . strtoupper($this->unit); } - return number_format($value, 2); + return number_format($value, 2) . ($this->unit !== null ? ' ' . $this->unit : ''); } /**