You are here

interface SensorResultInterface in Monitoring 7

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

29 files declare their use of SensorResultInterface
monitoring.admin.inc in ./monitoring.admin.inc
Admin page/form callbacks.
monitoring.api.php in ./monitoring.api.php
Monitoring API documentation.
monitoring.api.test in test/tests/monitoring.api.test
Contains \MonitoringApiTest.
monitoring.drush.inc in ./monitoring.drush.inc
Drush support for monitoring.
monitoring.module in ./monitoring.module
Monitoring bootstrap file.

... See full list

File

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

Namespace

Drupal\monitoring\Result
View source
interface SensorResultInterface {

  /**
   * Sensor status OK.
   *
   * @var string
   */
  const STATUS_OK = 'OK';

  /**
   * Sensor status INFO.
   *
   * @var string
   */
  const STATUS_INFO = 'INFO';

  /**
   * Sensor status WARNING.
   *
   * @var string
   */
  const STATUS_WARNING = 'WARNING';

  /**
   * Sensor status CRITICAL.
   *
   * @var string
   */
  const STATUS_CRITICAL = 'CRITICAL';

  /**
   * Sensor status UNKNOWN.
   *
   * @var string
   */
  const STATUS_UNKNOWN = 'UNKNOWN';

  /**
   * Gets sensor status.
   *
   * @return string
   *   Sensor status.
   */
  public function getStatus();

  /**
   * Gets a human readable label for the sensor status.
   *
   * @return string
   *   Sensor status label.
   */
  public function getStatusLabel();

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

  /**
   * Gets sensor status message.
   *
   * Must not be called on an uncompiled result.
   *
   * @return string
   *   Sensor status message.
   */
  public function getMessage();

  /**
   * 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.
   *
   * @see self::addStatusMessage()
   */
  public function setMessage($message, array $variables = array());

  /**
   * 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 self::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\Sensor\SensorInterface::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.
   *
   * @return mixed
   *   Whatever value the sensor is supposed to return.
   */
  public function getValue();

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

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

  /**
   * 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);

  /**
   * Get sensor execution time in ms.
   *
   * @return float
   */
  public function getExecutionTime();

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

  /**
   * 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();

  /**
   * The result data timestamp.
   *
   * @return int
   *   UNIX timestamp.
   */
  public function getTimestamp();

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

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

  /**
   * Gets sensor info.
   *
   * @return SensorInfo
   */
  public function getSensorInfo();

  /**
   * 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 string $verbose_output
   *   The verbose output as a string.
   */
  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 string
   *   The verbose output as a string.
   */
  public function getVerboseOutput();

}

Members

Namesort descending Modifiers Type Description Overrides
SensorResultInterface::addStatusMessage public function Adds sensor status message. 1
SensorResultInterface::compile public function Compiles added status messages sets the status. 1
SensorResultInterface::getExecutionTime public function Get sensor execution time in ms. 1
SensorResultInterface::getExpectedValue public function Gets the sensor expected value. 1
SensorResultInterface::getMessage public function Gets sensor status message. 1
SensorResultInterface::getSensorInfo public function Gets sensor info. 1
SensorResultInterface::getSensorName public function Gets sensor name. 1
SensorResultInterface::getStatus public function Gets sensor status. 1
SensorResultInterface::getStatusLabel public function Gets a human readable label for the sensor status. 1
SensorResultInterface::getTimestamp public function The result data timestamp. 1
SensorResultInterface::getValue public function Gets the sensor metric value. 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::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::STATUS_CRITICAL constant Sensor status CRITICAL.
SensorResultInterface::STATUS_INFO constant Sensor status INFO.
SensorResultInterface::STATUS_OK constant Sensor status OK.
SensorResultInterface::STATUS_UNKNOWN constant Sensor status UNKNOWN.
SensorResultInterface::STATUS_WARNING constant Sensor status WARNING.
SensorResultInterface::toArray public function Gets sensor result data as array. 1
SensorResultInterface::toNumber public function Casts/processes the sensor value into numeric representation. 1