function monitoring_dblog_monitoring_sensor_info in Monitoring 7
Implements monitoring_MODULE_monitoring_sensor_info().
Module: dblog
File
- ./
monitoring.monitoring_sensors.inc, line 221 - Define default sensors for core and contrib modules.
Code
function monitoring_dblog_monitoring_sensor_info() {
$info['dblog_404'] = array(
'label' => 'Page not found errors',
'description' => 'Page not found errors logged by watchdog',
'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorDblog404',
'value_label' => 'Watchdog events',
'settings' => array(
'category' => 'Watchdog',
// Cache for one hour.
'caching_time' => 3600,
'thresholds' => array(
'type' => 'exceeds',
'warning' => 20,
'critical' => 100,
),
'table' => 'watchdog',
'conditions' => array(
array(
'field' => 'type',
'value' => 'page not found',
),
),
'time_interval_field' => 'timestamp',
'time_interval_value' => 60 * 60 * 24,
),
);
$severities = monitoring_event_severities();
foreach (watchdog_severity_levels() as $level => $name) {
// Error level and higher cache for 5 minutes, the other 15.
if ($level <= WATCHDOG_ERROR) {
$caching_time = 300;
$critical_threshold = 5;
$warning_threshold = 1;
}
elseif (!in_array($level, array(
WATCHDOG_NOTICE,
WATCHDOG_INFO,
))) {
$caching_time = 900;
$critical_threshold = 50;
$warning_threshold = 20;
}
else {
$caching_time = 900;
$critical_threshold = NULL;
$warning_threshold = NULL;
}
$info['dblog_event_severity_' . $severities[$level]] = array(
'label' => format_string('Severity @severity', array(
'@severity' => $name,
)),
'description' => format_string('Watchdog entries of severity @severity', array(
'@severity' => $name,
)),
'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorDatabaseAggregator',
'value_label' => 'Events',
'settings' => array(
'category' => 'Watchdog',
'caching_time' => $caching_time,
'thresholds' => array(
'type' => 'exceeds',
'warning' => $warning_threshold,
'critical' => $critical_threshold,
),
'table' => 'watchdog',
'conditions' => array(
array(
'field' => 'severity',
'value' => $level,
),
),
'time_interval_field' => 'timestamp',
'time_interval_value' => 24 * 60 * 60,
),
);
}
$info['user_successful_logins'] = array(
'label' => 'Successful user logins',
'description' => 'Successful user logins by Watchdog',
'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorDatabaseAggregator',
'value_label' => 'Login attempts',
'settings' => array(
'category' => 'User activity',
// Cache for one hour.
'caching_time' => 3600,
'table' => 'watchdog',
'conditions' => array(
array(
'field' => 'type',
'value' => 'user',
),
array(
'field' => 'message',
'value' => 'Session opened for %name.',
),
),
'time_interval_field' => 'timestamp',
'time_interval_value' => 60 * 60 * 24,
),
);
$info['user_session_logouts'] = array(
'label' => 'User session logouts',
'description' => 'User session logouts by Watchdog',
'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorDatabaseAggregator',
'value_label' => 'Logouts',
'settings' => array(
'category' => 'User activity',
// Cache for one hour.
'caching time' => 3600,
'table' => 'watchdog',
'conditions' => array(
array(
'field' => 'type',
'value' => 'user',
),
array(
'field' => 'message',
'value' => 'Session closed for %name.',
),
),
'time_interval_field' => 'timestamp',
'time_interval_value' => 60 * 60 * 24,
),
);
$info['user_failed_logins'] = array(
'label' => 'Failed user logins',
'description' => 'Failed user logins by Watchdog',
'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorUserFailedLogins',
'value_label' => 'Login attempts',
'settings' => array(
'category' => 'User activity',
// Cache for one hour.
'caching_time' => 3600,
// If failed logins exceed some level we need to escalate. Default value
// will probably not fit all sites, especially larger once.
'thresholds' => array(
'type' => 'exceeds',
'warning' => 50,
'critical' => 120,
),
'table' => 'watchdog',
'conditions' => array(
array(
'field' => 'type',
'value' => 'user',
),
array(
'field' => 'message',
'value' => 'Login attempt failed for %user.',
),
),
'time_interval_field' => 'timestamp',
'time_interval_value' => 60 * 60 * 24,
),
);
// @todo: Provide an alternative for past_db.
if (module_exists('image')) {
$info['dblog_image_missing_style'] = array(
'label' => 'Image derivative creation fail',
'description' => 'Image derivative creation fails',
'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorImageMissingStyle',
'value_label' => 'Watchdog entries',
'settings' => array(
'category' => 'Watchdog',
// Cache for one hour.
'caching_time' => 3600,
'thresholds' => array(
'type' => 'exceeds',
'warning' => 5,
'critical' => 20,
),
'table' => 'watchdog',
'conditions' => array(
array(
'field' => 'type',
'value' => 'image',
),
array(
'field' => 'message',
'value' => 'Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.',
),
),
'time_interval_field' => 'timestamp',
'time_interval_value' => 60 * 60 * 24,
),
);
}
return $info;
}