You are here

function monitoring_sensor_result_save in Monitoring 7

Same name and namespace in other branches
  1. 8 monitoring.module \monitoring_sensor_result_save()

Saves the sensor result.

Parameters

SensorResultInterface $result: Sensor call result.

Return value

\Drupal\monitoring\Entity\SensorResultEntity Sensor result entity.

1 call to monitoring_sensor_result_save()
SensorRunner::logResults in lib/Drupal/monitoring/SensorRunner.php
Log results if needed.

File

./monitoring.module, line 451
Monitoring bootstrap file.

Code

function monitoring_sensor_result_save(SensorResultInterface $result) {
  $values = array(
    'sensor_name' => $result
      ->getSensorName(),
    'sensor_status' => $result
      ->getStatus(),
    'sensor_message' => $result
      ->getMessage(),
    'sensor_value' => $result
      ->getValue(),
    'timestamp' => $result
      ->getTimestamp(),
    'execution_time' => $result
      ->getExecutionTime(),
  );
  $result_entity = entity_create('monitoring_sensor_result', $values);
  entity_save('monitoring_sensor_result', $result_entity);
  return $result_entity;
}