You are here

public function NonExistingUserFailedLoginsSensorPlugin::verboseResultCounting in Monitoring 8

Get the verbose results of the attempts per ip.

Parameters

array $output: The output array, at which we will add the attempts per user result.

1 call to NonExistingUserFailedLoginsSensorPlugin::verboseResultCounting()
NonExistingUserFailedLoginsSensorPlugin::resultVerbose in src/Plugin/monitoring/SensorPlugin/NonExistingUserFailedLoginsSensorPlugin.php
Provide additional info about sensor call.

File

src/Plugin/monitoring/SensorPlugin/NonExistingUserFailedLoginsSensorPlugin.php, line 70
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\NonExistingUserFailedLoginsSensorPlugin.

Class

NonExistingUserFailedLoginsSensorPlugin
Monitors non existing user failed login from dblog messages.

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

Code

public function verboseResultCounting(array &$output) {
  if ($this->sensorConfig
    ->getSetting('verbose_fields')) {

    // Fetch the last 20 matching entries, aggregated.
    $query = $this
      ->getAggregateQuery();
    $query_result = $query
      ->range(0, 20)
      ->execute();
    $this->queryString = $query_result
      ->getQueryString();
    $rows = $this
      ->buildTableRows($query_result
      ->fetchAll());
    $results = [];
    foreach ($rows as $key => $row) {
      $results[$key] = [];
      $variables = unserialize($row['variables']);
      $results[$key]['ip'] = $variables['%ip'];
      $results[$key]['attempts'] = $row['records_count'];
    }
    $output['attempts_per_ip'] = array(
      '#type' => 'verbose_table_result',
      '#title' => t('Attempts per ip'),
      '#rows' => $results,
      '#header' => $this
        ->buildTableHeader($results),
      '#query' => $query_result
        ->getQueryString(),
      '#query_args' => $query
        ->getArguments(),
    );
  }
}