You are here

protected function Thresholds::exceeds in Monitoring 7

Same name and namespace in other branches
  1. 8 src/Sensor/Thresholds.php \Drupal\monitoring\Sensor\Thresholds::exceeds()

Checks if provided value exceeds the configured threshold.

Parameters

int $value: The value to check.

Return value

int|null A sensor status or NULL.

File

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

Class

Thresholds
Determine status based on thresholds during sensor run.

Namespace

Drupal\monitoring\Sensor

Code

protected function exceeds($value) {
  if (($threshold = $this->sensorInfo
    ->getThresholdValue('critical')) !== NULL && $value > $threshold) {
    $this->message = format_string('exceeds @expected', array(
      '@expected' => $threshold,
    ));
    return SensorResultInterface::STATUS_CRITICAL;
  }
  if (($threshold = $this->sensorInfo
    ->getThresholdValue('warning')) !== NULL && $value > $threshold) {
    $this->message = format_string('exceeds @expected', array(
      '@expected' => $threshold,
    ));
    return SensorResultInterface::STATUS_WARNING;
  }
}