You are here

protected function Thresholds::inner_interval in Monitoring 8

Same name and namespace in other branches
  1. 7 lib/Drupal/monitoring/Sensor/Thresholds.php \Drupal\monitoring\Sensor\Thresholds::inner_interval()

Checks if provided value falls inside 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 129
Contains \Drupal\monitoring\Sensor\Thresholds.

Class

Thresholds
Determine status based on thresholds during sensor run.

Namespace

Drupal\monitoring\Sensor

Code

protected function inner_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('violating the 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('violating the interval @low - @high', array(
        '@low' => $low,
        '@high' => $high,
      ));
      return SensorResultInterface::STATUS_WARNING;
    }
  }
}