Perfdata: print warn and crit human-readable if the start is -∞
refs #8194
This commit is contained in:
parent
2270e250d3
commit
54002cb3e5
|
@ -72,6 +72,20 @@ 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
|
||||
*
|
||||
|
@ -307,23 +321,27 @@ class Perfdata
|
|||
}
|
||||
/* @noinspection PhpMissingBreakStatementInspection */
|
||||
case 3:
|
||||
$this->rawCriticalThreshold = trim($parts[2]);
|
||||
$this->criticalThreshold = self::convert(
|
||||
ThresholdRange::fromString(trim($parts[2]) ?: '~:'),
|
||||
ThresholdRange::fromString($this->rawCriticalThreshold ?: '~:'),
|
||||
$this->unit
|
||||
);
|
||||
// Fallthrough
|
||||
case 2:
|
||||
$this->rawWarningThreshold = trim($parts[1]);
|
||||
$this->warningThreshold = self::convert(
|
||||
ThresholdRange::fromString(trim($parts[1]) ?: '~:'),
|
||||
ThresholdRange::fromString($this->rawWarningThreshold ?: '~:'),
|
||||
$this->unit
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->warningThreshold === null) {
|
||||
$this->warningThreshold = new ThresholdRange();
|
||||
$this->rawWarningThreshold = '';
|
||||
}
|
||||
if ($this->criticalThreshold === null) {
|
||||
$this->criticalThreshold = new ThresholdRange();
|
||||
$this->rawCriticalThreshold = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,6 +465,20 @@ class Perfdata
|
|||
|
||||
public function toArray()
|
||||
{
|
||||
if ($this->warningThreshold->getMin() === null) {
|
||||
$max = $this->warningThreshold->getMax();
|
||||
$warn = $max === null ? '∞' : $this->format($max);
|
||||
} else {
|
||||
$warn = $this->rawWarningThreshold;
|
||||
}
|
||||
|
||||
if ($this->criticalThreshold->getMin() === null) {
|
||||
$max = $this->criticalThreshold->getMax();
|
||||
$crit = $max === null ? '∞' : $this->format($max);
|
||||
} else {
|
||||
$crit = $this->rawCriticalThreshold;
|
||||
}
|
||||
|
||||
return array(
|
||||
'label' => $this->getLabel(),
|
||||
'value' => $this->format($this->getvalue()),
|
||||
|
@ -456,8 +488,8 @@ class Perfdata
|
|||
'max' => isset($this->maxValue) && !$this->isPercentage()
|
||||
? $this->format($this->maxValue)
|
||||
: '',
|
||||
'warn' => (string) $this->warningThreshold,
|
||||
'crit' => (string) $this->criticalThreshold
|
||||
'warn' => $warn,
|
||||
'crit' => $crit
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue