You are here

class SensorDblog404 in Monitoring 7

Monitors 404 page errors from dblog.

Displays URL with highest occurrence as message.

Hierarchy

Expanded class hierarchy of SensorDblog404

File

lib/Drupal/monitoring/Sensor/Sensors/SensorDblog404.php, line 16
Contains \Drupal\monitoring\Sensor\Sensors\SensorDblog404.

Namespace

Drupal\monitoring\Sensor\Sensors
View source
class SensorDblog404 extends SensorDatabaseAggregator {

  /**
   * {@inheritdoc}
   */
  public function buildQuery() {
    $query = parent::buildQuery();
    $query
      ->addField('watchdog', 'message');

    // The message is the requested 404 URL.
    $query
      ->groupBy('message');
    $query
      ->orderBy('records_count', 'DESC');
    $query
      ->range(0, 1);
    return $query;
  }

  /**
   * {@inheritdoc}
   */
  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);
    }
  }

}

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
SensorDatabaseAggregator::$fetchedObject protected property The fetched object from the query result.
SensorDatabaseAggregator::$queryArguments protected property The arguments of the executed query.
SensorDatabaseAggregator::$queryResult protected property The result of the db query execution.
SensorDatabaseAggregator::buildQueryAggregate protected function Adds aggregate expressions to the query.
SensorDatabaseAggregator::fetchObject public function Get fetched object from the executed query.
SensorDatabaseAggregator::getEntityTypeFromTable protected function Returns the entity type for a given base table.
SensorDatabaseAggregator::getFieldName protected function Returns the field name to use for a condition and ensures necessary joins.
SensorDatabaseAggregator::getQueryArguments protected function Returns query arguments of the last executed query.
SensorDatabaseAggregator::getQueryResult protected function Executes the query and returns the result.
SensorDatabaseAggregator::getTimeIntervalOptions protected function Returns time interval options.
SensorDatabaseAggregator::joinFieldTable protected function Joins the field data table for a given field.
SensorDatabaseAggregator::resultVerbose public function Provide additional info about sensor call. Overrides SensorExtendedInfoInterface::resultVerbose 1
SensorDatabaseAggregator::settingsForm public function Gets settings form for a specific sensor. Overrides SensorThresholds::settingsForm 1
SensorDblog404::buildQuery public function Builds the database query. Overrides SensorDatabaseAggregator::buildQuery
SensorDblog404::runSensor public function Runs the sensor, updating $sensor_result. Overrides SensorDatabaseAggregator::runSensor
SensorThresholds::setFormError protected function Sets a form error for the given threshold key.
SensorThresholds::settingsFormValidate public function Form validator for a sensor settings form. Overrides SensorConfigurable::settingsFormValidate