SensorDblog404.php in Monitoring 7
File
lib/Drupal/monitoring/Sensor/Sensors/SensorDblog404.php
View source
<?php
namespace Drupal\monitoring\Sensor\Sensors;
use Drupal\monitoring\Result\SensorResultInterface;
class SensorDblog404 extends SensorDatabaseAggregator {
public function buildQuery() {
$query = parent::buildQuery();
$query
->addField('watchdog', 'message');
$query
->groupBy('message');
$query
->orderBy('records_count', 'DESC');
$query
->range(0, 1);
return $query;
}
public function runSensor(SensorResultInterface $result) {
parent::runSensor($result);
$query_result = $this
->fetchObject();
if (!empty($query_result) && !empty($query_result->message)) {
$result
->addStatusMessage($query_result->message);
}
}
}