mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
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;
|
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
|
* Create a new Perfdata object based on the given performance data label and value
|
||||||
*
|
*
|
||||||
@ -307,23 +321,27 @@ class Perfdata
|
|||||||
}
|
}
|
||||||
/* @noinspection PhpMissingBreakStatementInspection */
|
/* @noinspection PhpMissingBreakStatementInspection */
|
||||||
case 3:
|
case 3:
|
||||||
|
$this->rawCriticalThreshold = trim($parts[2]);
|
||||||
$this->criticalThreshold = self::convert(
|
$this->criticalThreshold = self::convert(
|
||||||
ThresholdRange::fromString(trim($parts[2]) ?: '~:'),
|
ThresholdRange::fromString($this->rawCriticalThreshold ?: '~:'),
|
||||||
$this->unit
|
$this->unit
|
||||||
);
|
);
|
||||||
// Fallthrough
|
// Fallthrough
|
||||||
case 2:
|
case 2:
|
||||||
|
$this->rawWarningThreshold = trim($parts[1]);
|
||||||
$this->warningThreshold = self::convert(
|
$this->warningThreshold = self::convert(
|
||||||
ThresholdRange::fromString(trim($parts[1]) ?: '~:'),
|
ThresholdRange::fromString($this->rawWarningThreshold ?: '~:'),
|
||||||
$this->unit
|
$this->unit
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->warningThreshold === null) {
|
if ($this->warningThreshold === null) {
|
||||||
$this->warningThreshold = new ThresholdRange();
|
$this->warningThreshold = new ThresholdRange();
|
||||||
|
$this->rawWarningThreshold = '';
|
||||||
}
|
}
|
||||||
if ($this->criticalThreshold === null) {
|
if ($this->criticalThreshold === null) {
|
||||||
$this->criticalThreshold = new ThresholdRange();
|
$this->criticalThreshold = new ThresholdRange();
|
||||||
|
$this->rawCriticalThreshold = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,6 +465,20 @@ class Perfdata
|
|||||||
|
|
||||||
public function toArray()
|
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(
|
return array(
|
||||||
'label' => $this->getLabel(),
|
'label' => $this->getLabel(),
|
||||||
'value' => $this->format($this->getvalue()),
|
'value' => $this->format($this->getvalue()),
|
||||||
@ -456,8 +488,8 @@ class Perfdata
|
|||||||
'max' => isset($this->maxValue) && !$this->isPercentage()
|
'max' => isset($this->maxValue) && !$this->isPercentage()
|
||||||
? $this->format($this->maxValue)
|
? $this->format($this->maxValue)
|
||||||
: '',
|
: '',
|
||||||
'warn' => (string) $this->warningThreshold,
|
'warn' => $warn,
|
||||||
'crit' => (string) $this->criticalThreshold
|
'crit' => $crit
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user