You are here

interface SensorResultInterface in Monitoring 8

Same name and namespace in other branches
  1. 7 lib/Drupal/monitoring/Result/SensorResultInterface.php \Drupal\monitoring\Result\SensorResultInterface

Interface for a sensor result.

@todo more

Hierarchy

Expanded class hierarchy of SensorResultInterface

All classes that implement SensorResultInterface

42 files declare their use of SensorResultInterface
CommerceTurnoverSensorPlugin.php in src/Plugin/monitoring/SensorPlugin/CommerceTurnoverSensorPlugin.php
ContentEntityAggregatorSensorPlugin.php in src/Plugin/monitoring/SensorPlugin/ContentEntityAggregatorSensorPlugin.php
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\ContentEntityAggregatorSensorPlugin.
CoreRequirementsSensorPlugin.php in src/Plugin/monitoring/SensorPlugin/CoreRequirementsSensorPlugin.php
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\CoreRequirementsSensorPlugin.
CronLastRunAgeSensorPlugin.php in src/Plugin/monitoring/SensorPlugin/CronLastRunAgeSensorPlugin.php
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\CronLastRunAgeSensorPlugin.
DatabaseAggregatorSensorPlugin.php in src/Plugin/monitoring/SensorPlugin/DatabaseAggregatorSensorPlugin.php
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\DatabaseAggregatorSensorPlugin.

... See full list

File

src/Result/SensorResultInterface.php, line 16
Contains \Drupal\monitoring\Result\SensorResultInterface.

Namespace

Drupal\monitoring\Result
View source
interface SensorResultInterface extends SensorResultDataInterface {

  /**
   * Adds sensor status message.
   *
   * Multiple status messages can be added to a single result and will be added
   * to the final status message.
   *
   * @param string $message
   *   Message to be set.
   * @param array $variables
   *   Dynamic values to be replaced for placeholders in the message.
   *
   * @see \Drupal\monitoring\Result\SensorResultInterface::setMessage()
   */
  public function addStatusMessage($message, array $variables = array());

  /**
   * Compiles added status messages sets the status.
   *
   * If the status is STATUS_UNKNOWN, this will attempt to set the status
   * based on expected value and threshold configurations. See
   * \Drupal\monitoring\SensorPlugin\SensorPluginInterface::runSensor() for details.
   *
   * @throws \Drupal\monitoring\Sensor\SensorCompilationException
   *   Thrown if an error occurs during the sensor result compilation.
   */
  public function compile();

  /**
   * Gets the sensor metric value formatted for UI output.
   *
   * @param mixed $value
   *   Sensor result value.
   *
   * @return mixed
   *   Whatever value the sensor is supposed to return.
   */
  public function getFormattedValue($value);

  /**
   * Gets the sensor expected value.
   *
   * @return mixed
   *   Whatever value the sensor is supposed to return.
   */
  public function getExpectedValue();

  /**
   * Sets sensor status.
   *
   * @param string $status
   *   One of SensorResultInterface::STATUS_* constants.
   */
  public function setStatus($status);

  /**
   * Sets sensor value.
   *
   * @param mixed $value
   */
  public function setValue($value);

  /**
   * Sets the final result message.
   *
   * If this is set, then the compilation will not extend the message in any
   * way and the sensor completely responsible for making sure that all
   * relevant information like the sensor value is part of the message.
   *
   * @param string $message
   *   Message to be set.
   * @param array $variables
   *   Dynamic values to be replaced for placeholders in the message.
   */
  public function setMessage($message, array $variables = array());

  /**
   * Sets sensor execution time in ms.
   *
   * @param float $time
   *   Sensor execution time in ms.
   */
  public function setExecutionTime($time);

  /**
   * Sets sensor expected value.
   *
   * Set to NULL if you want to prevent the default sensor result assessment.
   * Use 0/FALSE values instead.
   *
   * In case an interval is expected, do not set the expected value, thresholds
   * are used instead.
   *
   * The expected value is not considered when thresholds are configured.
   *
   * @param mixed $value
   */
  public function setExpectedValue($value);

  /**
   * Casts/processes the sensor value into numeric representation.
   *
   * @return number
   *   Numeric sensor value.
   */
  public function toNumber();

  /**
   * Determines if data for given result object are cached.
   *
   * @return boolean
   *   Cached flag.
   */
  public function isCached();

  /**
   * Gets sensor result data as array.
   *
   * @return array
   *   Sensor result data as array.
   */
  public function toArray();

  /**
   * Gets sensor name.
   *
   * @return string
   */
  public function getSensorId();

  /**
   * Gets sensor config.
   *
   * @return \Drupal\monitoring\Entity\SensorConfig
   */
  public function getSensorConfig();

  /**
   * Checks if sensor is in UNKNOWN state.
   *
   * @return boolean
   */
  public function isUnknown();

  /**
   * Checks if sensor is in WARNING state.
   *
   * @return boolean
   */
  public function isWarning();

  /**
   * Checks if sensor is in CRITICAL state.
   *
   * @return boolean
   */
  public function isCritical();

  /**
   * Checks if sensor is in OK state.
   *
   * @return boolean
   */
  public function isOk();

  /**
   * Set the verbose output.
   *
   * @param array $verbose_output
   *   The verbose output as a render array.
   */
  public function setVerboseOutput($verbose_output);

  /**
   * Returns the verbose output.
   *
   * Verbose output is not persisted and is only available if the sensor result
   * is not cached.
   *
   * @return array
   *   The verbose output as a render array.
   */
  public function getVerboseOutput();

  /**
   * Sets the previous sensor result.
   *
   * @param \Drupal\monitoring\Entity\SensorResultDataInterface|null $previous_result
   *   A SensorResultEntity representing the previous sensor result to set.
   *   NULL if there is no previous result.
   */
  public function setPreviousResult(SensorResultDataInterface $previous_result = NULL);

  /**
   * Gets the previous sensor result.
   *
   * @return \Drupal\monitoring\Entity\SensorResultDataInterface|null
   *   A SensorResultEntity representing the previous sensor result. NULL if
   *   there is no previous result.
   */
  public function getPreviousResult();

}

Members

Namesort descending Modifiers Type Description Overrides
SensorResultDataInterface::getExecutionTime public function Get sensor execution time in ms. 2
SensorResultDataInterface::getMessage public function Gets sensor status message. 2
SensorResultDataInterface::getStatus public function Gets sensor status. 2
SensorResultDataInterface::getStatusLabel public function Gets a human readable label for the sensor status. 2
SensorResultDataInterface::getTimestamp public function The result data timestamp. 2
SensorResultDataInterface::getValue public function Gets the sensor metric value. 2
SensorResultDataInterface::STATUS_CRITICAL constant Sensor status CRITICAL.
SensorResultDataInterface::STATUS_INFO constant Sensor status INFO.
SensorResultDataInterface::STATUS_OK constant Sensor status OK.
SensorResultDataInterface::STATUS_UNKNOWN constant Sensor status UNKNOWN.
SensorResultDataInterface::STATUS_WARNING constant Sensor status WARNING.
SensorResultInterface::addStatusMessage public function Adds sensor status message. 1
SensorResultInterface::compile public function Compiles added status messages sets the status. 1
SensorResultInterface::getExpectedValue public function Gets the sensor expected value. 1
SensorResultInterface::getFormattedValue public function Gets the sensor metric value formatted for UI output. 1
SensorResultInterface::getPreviousResult public function Gets the previous sensor result. 1
SensorResultInterface::getSensorConfig public function Gets sensor config. 1
SensorResultInterface::getSensorId public function Gets sensor name. 1
SensorResultInterface::getVerboseOutput public function Returns the verbose output. 1
SensorResultInterface::isCached public function Determines if data for given result object are cached. 1
SensorResultInterface::isCritical public function Checks if sensor is in CRITICAL state. 1
SensorResultInterface::isOk public function Checks if sensor is in OK state. 1
SensorResultInterface::isUnknown public function Checks if sensor is in UNKNOWN state. 1
SensorResultInterface::isWarning public function Checks if sensor is in WARNING state. 1
SensorResultInterface::setExecutionTime public function Sets sensor execution time in ms. 1
SensorResultInterface::setExpectedValue public function Sets sensor expected value. 1
SensorResultInterface::setMessage public function Sets the final result message. 1
SensorResultInterface::setPreviousResult public function Sets the previous sensor result. 1
SensorResultInterface::setStatus public function Sets sensor status. 1
SensorResultInterface::setValue public function Sets sensor value. 1
SensorResultInterface::setVerboseOutput public function Set the verbose output. 1
SensorResultInterface::toArray public function Gets sensor result data as array. 1
SensorResultInterface::toNumber public function Casts/processes the sensor value into numeric representation. 1