You are here

class SensorElysiaCron in Monitoring 7

Monitors elysia cron channels for last execution.

Hierarchy

Expanded class hierarchy of SensorElysiaCron

File

lib/Drupal/monitoring/Sensor/Sensors/SensorElysiaCron.php, line 15
Contains \Drupal\monitoring\Sensor\Sensors\SensorElysiaCron.

Namespace

Drupal\monitoring\Sensor\Sensors
View source
class SensorElysiaCron extends SensorThresholds {

  /**
   * {@inheritdoc}
   */
  public function runSensor(SensorResultInterface $result) {

    // The channel name.
    $name = $this->info
      ->getSetting('name');
    $query = db_select('elysia_cron', 'e')
      ->fields('e', array(
      $this->info
        ->getSetting('metric'),
    ));
    $query
      ->condition('name', $name);
    $value = $query
      ->execute()
      ->fetchField();

    // In case we are querying for last_run, the value is the seconds ago.
    if ($this->info
      ->getSetting('metric') == 'last_run') {
      $value = REQUEST_TIME - $value;
      $result
        ->addStatusMessage('@time ago', array(
        '@time' => format_interval($value),
      ));
    }
    else {

      // metric last_execution_time
      $result
        ->addStatusMessage('at @time', array(
        '@time' => format_date($value),
      ));
    }
    $result
      ->setValue($value);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Sensor::$info protected property Current sensor info object.
Sensor::getSensorName public function Gets sensor name (not the label). Overrides SensorInterface::getSensorName
Sensor::isEnabled public function Determines if sensor is enabled. Overrides SensorInterface::isEnabled
Sensor::__construct function Instantiates a sensor object. 1
SensorElysiaCron::runSensor public function Runs the sensor, updating $sensor_result. Overrides SensorInterface::runSensor
SensorThresholds::setFormError protected function Sets a form error for the given threshold key.
SensorThresholds::settingsForm public function Gets settings form for a specific sensor. Overrides SensorConfigurable::settingsForm 1
SensorThresholds::settingsFormValidate public function Form validator for a sensor settings form. Overrides SensorConfigurable::settingsFormValidate