protected function Thresholds::outer_interval in Monitoring 8
Same name and namespace in other branches
- 7 lib/Drupal/monitoring/Sensor/Thresholds.php \Drupal\monitoring\Sensor\Thresholds::outer_interval()
Checks if provided value is outside of the configured interval.
Parameters
int $value: The value to check.
Return value
int|null A sensor status or NULL.
File
- src/
Sensor/ Thresholds.php, line 153 - Contains \Drupal\monitoring\Sensor\Thresholds.
Class
- Thresholds
- Determine status based on thresholds during sensor run.
Namespace
Drupal\monitoring\SensorCode
protected function outer_interval($value) {
if (($low = $this->sensorConfig
->getThresholdValue('critical_low')) !== NULL && ($high = $this->sensorConfig
->getThresholdValue('critical_high')) !== NULL) {
if ($value < $low || $value > $high) {
$this->message = new FormattableMarkup('outside the allowed interval @low - @high', array(
'@low' => $low,
'@high' => $high,
));
return SensorResultInterface::STATUS_CRITICAL;
}
}
if (($low = $this->sensorConfig
->getThresholdValue('warning_low')) !== NULL && ($high = $this->sensorConfig
->getThresholdValue('warning_high')) !== NULL) {
if ($value < $low || $value > $high) {
$this->message = new FormattableMarkup('outside the allowed interval @low - @high', array(
'@low' => $low,
'@high' => $high,
));
return SensorResultInterface::STATUS_WARNING;
}
}
}