You are here

protected function Thresholds::outer_interval in Monitoring 7

Same name and namespace in other branches
  1. 8 src/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

lib/Drupal/monitoring/Sensor/Thresholds.php, line 151
Contains \Drupal\monitoring\Sensor\Thresholds.

Class

Thresholds
Determine status based on thresholds during sensor run.

Namespace

Drupal\monitoring\Sensor

Code

protected function outer_interval($value) {
  if (($low = $this->sensorInfo
    ->getThresholdValue('critical_low')) !== NULL && ($high = $this->sensorInfo
    ->getThresholdValue('critical_high')) !== NULL) {
    if ($value < $low || $value > $high) {
      $this->message = format_string('outside the allowed interval @low - @high', array(
        '@low' => $low,
        '@high' => $high,
      ));
      return SensorResultInterface::STATUS_CRITICAL;
    }
  }
  if (($low = $this->sensorInfo
    ->getThresholdValue('warning_low')) !== NULL && ($high = $this->sensorInfo
    ->getThresholdValue('warning_high')) !== NULL) {
    if ($value < $low || $value > $high) {
      $this->message = format_string('outside the allowed interval @low - @high', array(
        '@low' => $low,
        '@high' => $high,
      ));
      return SensorResultInterface::STATUS_WARNING;
    }
  }
}