Perfdata: Render unknown UOMs as-is
This commit is contained in:
parent
5b8bbf0d32
commit
e7bc0a136b
|
@ -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 : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue