class SensorUserFailedLogins in Monitoring 7
Monitors user failed login from dblog messages.
Helps to identify bots or brute force attacks.
Hierarchy
- class \Drupal\monitoring\Sensor\Sensor implements SensorInterface
- class \Drupal\monitoring\Sensor\SensorConfigurable implements SensorConfigurableInterface
- class \Drupal\monitoring\Sensor\SensorThresholds implements SensorThresholdsInterface
- class \Drupal\monitoring\Sensor\Sensors\SensorDatabaseAggregator implements SensorExtendedInfoInterface
- class \Drupal\monitoring\Sensor\Sensors\SensorUserFailedLogins
- class \Drupal\monitoring\Sensor\Sensors\SensorDatabaseAggregator implements SensorExtendedInfoInterface
- class \Drupal\monitoring\Sensor\SensorThresholds implements SensorThresholdsInterface
- class \Drupal\monitoring\Sensor\SensorConfigurable implements SensorConfigurableInterface
Expanded class hierarchy of SensorUserFailedLogins
File
- lib/
Drupal/ monitoring/ Sensor/ Sensors/ SensorUserFailedLogins.php, line 16 - Contains \Drupal\monitoring\Sensor\Sensors\SensorUserFailedLogins.
Namespace
Drupal\monitoring\Sensor\SensorsView source
class SensorUserFailedLogins extends SensorDatabaseAggregator {
/**
* {@inheritdoc}
*/
public function buildQuery() {
$query = parent::buildQuery();
$query
->addField('watchdog', 'variables');
$query
->groupBy('watchdog.variables');
return $query;
}
/**
* {@inheritdoc}
*/
public function runSensor(SensorResultInterface $result) {
$records_count = 0;
foreach ($this
->getQueryResult()
->fetchAll() as $row) {
$records_count += $row->records_count;
$variables = unserialize($row->variables);
$result
->addStatusMessage('@user: @count', array(
'@user' => $variables['%user'],
'@count' => $row->records_count,
));
}
$result
->setValue($records_count);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Sensor:: |
protected | property | Current sensor info object. | |
Sensor:: |
public | function |
Gets sensor name (not the label). Overrides SensorInterface:: |
|
Sensor:: |
public | function |
Determines if sensor is enabled. Overrides SensorInterface:: |
|
Sensor:: |
function | Instantiates a sensor object. | 1 | |
SensorDatabaseAggregator:: |
protected | property | The fetched object from the query result. | |
SensorDatabaseAggregator:: |
protected | property | The arguments of the executed query. | |
SensorDatabaseAggregator:: |
protected | property | The result of the db query execution. | |
SensorDatabaseAggregator:: |
protected | function | Adds aggregate expressions to the query. | |
SensorDatabaseAggregator:: |
public | function | Get fetched object from the executed query. | |
SensorDatabaseAggregator:: |
protected | function | Returns the entity type for a given base table. | |
SensorDatabaseAggregator:: |
protected | function | Returns the field name to use for a condition and ensures necessary joins. | |
SensorDatabaseAggregator:: |
protected | function | Returns query arguments of the last executed query. | |
SensorDatabaseAggregator:: |
protected | function | Executes the query and returns the result. | |
SensorDatabaseAggregator:: |
protected | function | Returns time interval options. | |
SensorDatabaseAggregator:: |
protected | function | Joins the field data table for a given field. | |
SensorDatabaseAggregator:: |
public | function |
Provide additional info about sensor call. Overrides SensorExtendedInfoInterface:: |
1 |
SensorDatabaseAggregator:: |
public | function |
Gets settings form for a specific sensor. Overrides SensorThresholds:: |
1 |
SensorThresholds:: |
protected | function | Sets a form error for the given threshold key. | |
SensorThresholds:: |
public | function |
Form validator for a sensor settings form. Overrides SensorConfigurable:: |
|
SensorUserFailedLogins:: |
public | function |
Builds the database query. Overrides SensorDatabaseAggregator:: |
|
SensorUserFailedLogins:: |
public | function |
Runs the sensor, updating $sensor_result. Overrides SensorDatabaseAggregator:: |