You are here

public function Thresholds::getMatchedThreshold in Monitoring 8

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

Gets status based on given value.

Note that if the threshold value is NULL or an empty string no assessment will be carried out therefore the OK value will be returned.

Parameters

int $value: The sensor value to assess.

Return value

int The assessed sensor status.

File

src/Sensor/Thresholds.php, line 56
Contains \Drupal\monitoring\Sensor\Thresholds.

Class

Thresholds
Determine status based on thresholds during sensor run.

Namespace

Drupal\monitoring\Sensor

Code

public function getMatchedThreshold($value) {
  if (method_exists($this, $this->sensorConfig
    ->getThresholdsType())) {
    $status = $this
      ->{$this->sensorConfig
      ->getThresholdsType()}($value);
    if ($status !== NULL) {
      return $status;
    }
    return SensorResultInterface::STATUS_OK;
  }
  else {
    $this->message = new FormattableMarkup('Unknown threshold type @type', array(
      '@type' => $this->sensorConfig
        ->getThresholdsType(),
    ));
    return SensorResultInterface::STATUS_CRITICAL;
  }
}