function monitoring_sensor_result_save in Monitoring 8
Same name and namespace in other branches
- 7 monitoring.module \monitoring_sensor_result_save()
Saves the sensor result.
Parameters
\Drupal\monitoring\Result\SensorResultInterface $result: Sensor call result.
Return value
\Drupal\monitoring\Entity\SensorResultEntity Sensor result entity.
1 call to monitoring_sensor_result_save()
- SensorRunner::logResults in src/
SensorRunner.php - Log results if needed.
File
- ./
monitoring.module, line 241 - Monitoring bootstrap file.
Code
function monitoring_sensor_result_save(SensorResultInterface $result) {
$values = array(
'sensor_name' => $result
->getSensorId(),
'sensor_status' => $result
->getStatus(),
'sensor_message' => $result
->getMessage(),
'sensor_value' => $result
->getValue(),
'timestamp' => $result
->getTimestamp(),
'execution_time' => $result
->getExecutionTime(),
);
$result_entity = SensorResultEntity::create($values);
$result_entity
->save();
return $result_entity;
}