You are here

protected function Thresholds::inner_interval in Monitoring 7

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

lib/Drupal/monitoring/Sensor/Thresholds.php, line 127
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->sensorInfo
    ->getThresholdValue('critical_low')) !== NULL && ($high = $this->sensorInfo
    ->getThresholdValue('critical_high')) !== NULL) {
    if ($value > $low && $value < $high) {
      $this->message = format_string('violating the 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('violating the interval @low - @high', array(
        '@low' => $low,
        '@high' => $high,
      ));
      return SensorResultInterface::STATUS_WARNING;
    }
  }
}