diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index 6c2d89a72..44e377a3e 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -72,20 +72,6 @@ class Perfdata */ protected $criticalThreshold; - /** - * The WARNING threshold as got from the plugin - * - * @var string - */ - protected $rawWarningThreshold; - - /** - * The CRITICAL threshold as got from the plugin - * - * @var string - */ - protected $rawCriticalThreshold; - /** * Create a new Perfdata object based on the given performance data label and value * @@ -321,27 +307,23 @@ class Perfdata } /* @noinspection PhpMissingBreakStatementInspection */ case 3: - $this->rawCriticalThreshold = trim($parts[2]); $this->criticalThreshold = self::convert( - ThresholdRange::fromString($this->rawCriticalThreshold), + ThresholdRange::fromString(trim($parts[2])), $this->unit ); // Fallthrough case 2: - $this->rawWarningThreshold = trim($parts[1]); $this->warningThreshold = self::convert( - ThresholdRange::fromString($this->rawWarningThreshold), + ThresholdRange::fromString(trim($parts[1])), $this->unit ); } if ($this->warningThreshold === null) { $this->warningThreshold = new ThresholdRange(); - $this->rawWarningThreshold = ''; } if ($this->criticalThreshold === null) { $this->criticalThreshold = new ThresholdRange(); - $this->rawCriticalThreshold = ''; } } @@ -469,14 +451,14 @@ class Perfdata $max = $this->warningThreshold->getMax(); $warn = $max === null ? '∞' : $this->format($max); } else { - $warn = $this->rawWarningThreshold; + $warn = (string) $this->warningThreshold; } if ($this->criticalThreshold->getMin() === null) { $max = $this->criticalThreshold->getMax(); $crit = $max === null ? '∞' : $this->format($max); } else { - $crit = $this->rawCriticalThreshold; + $crit = (string) $this->criticalThreshold; } return array( diff --git a/modules/monitoring/library/Monitoring/Plugin/ThresholdRange.php b/modules/monitoring/library/Monitoring/Plugin/ThresholdRange.php index 536dc8f7a..59a9a1fab 100644 --- a/modules/monitoring/library/Monitoring/Plugin/ThresholdRange.php +++ b/modules/monitoring/library/Monitoring/Plugin/ThresholdRange.php @@ -29,6 +29,13 @@ class ThresholdRange */ protected $inverted = false; + /** + * The unmodified range as passed to fromString() + * + * @var string + */ + protected $raw; + /** * Create a new instance based on a threshold range conforming to * @@ -39,6 +46,7 @@ class ThresholdRange public static function fromString($rawRange = '') { $range = new static(); + $range->raw = $rawRange; if ($rawRange === '') { return $range; @@ -166,13 +174,6 @@ class ThresholdRange */ public function __toString() { - if ($this->min === null) { - $res = '~:'; - } else { - $res = $this->min === 0.0 ? '' : $this->min . ':'; - } - $res .= $this->max === null ? '' : $this->max; - - return ($this->inverted ? '@' : '') . (empty($res) ? '0:' : $res); + return (string) $this->raw; } }