Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/smshex_r.../opt/sharedra.../oldrads
File: autosuspend.py
#!/opt/imh-python/bin/python3
[0] Fix | Delete
"""Automatic resource overage suspension script"""
[1] Fix | Delete
import datetime
[2] Fix | Delete
import socket
[3] Fix | Delete
import sys
[4] Fix | Delete
import re
[5] Fix | Delete
import sh
[6] Fix | Delete
import time
[7] Fix | Delete
import yaml
[8] Fix | Delete
import os
[9] Fix | Delete
import configparser
[10] Fix | Delete
import pp_api
[11] Fix | Delete
import logging
[12] Fix | Delete
import pwd
[13] Fix | Delete
from collections import defaultdict
[14] Fix | Delete
from multiprocessing import cpu_count
[15] Fix | Delete
from functools import partial
[16] Fix | Delete
from rads.shared import (
[17] Fix | Delete
is_suspended,
[18] Fix | Delete
is_cpanel_user,
[19] Fix | Delete
get_secure_username,
[20] Fix | Delete
SYS_USERS,
[21] Fix | Delete
)
[22] Fix | Delete
[23] Fix | Delete
[24] Fix | Delete
class Autosuspend:
[25] Fix | Delete
"""
[26] Fix | Delete
Gathers current and historic user cp usage data and determines
[27] Fix | Delete
whether or not to enact an account suspension, send a warning
[28] Fix | Delete
or pass over system users
[29] Fix | Delete
"""
[30] Fix | Delete
[31] Fix | Delete
config_files = [
[32] Fix | Delete
'/opt/sharedrads/etc/autosuspend.cfg',
[33] Fix | Delete
'/opt/sharedrads/etc/autosuspend.cfg.local',
[34] Fix | Delete
]
[35] Fix | Delete
[36] Fix | Delete
brand = ('imh', 'hub')['hub' in socket.gethostname()]
[37] Fix | Delete
[38] Fix | Delete
def __init__(self):
[39] Fix | Delete
"""
[40] Fix | Delete
Initializes an instance of Autosuspend, including a logging
[41] Fix | Delete
object, parsed config from Autosuspend.config_files and
[42] Fix | Delete
various information on system users
[43] Fix | Delete
"""
[44] Fix | Delete
self.config = configparser.ConfigParser(allow_no_value=False)
[45] Fix | Delete
self.config.read(self.config_files)
[46] Fix | Delete
[47] Fix | Delete
logging.basicConfig(
[48] Fix | Delete
level=logging.INFO,
[49] Fix | Delete
format=f'%(asctime)s {sys.argv[0]}: %(message)s',
[50] Fix | Delete
datefmt='%Y-%m-%d:%H:%M:%S %Z',
[51] Fix | Delete
filename=self.suspension_log,
[52] Fix | Delete
)
[53] Fix | Delete
self.logger = logging.getLogger('suspension_logger')
[54] Fix | Delete
[55] Fix | Delete
self.priors = prior_events(
[56] Fix | Delete
data_file=self.data_file,
[57] Fix | Delete
log=self.suspension_log,
[58] Fix | Delete
log_offset=self.suspension_log_offset,
[59] Fix | Delete
)
[60] Fix | Delete
[61] Fix | Delete
self.suspensions_enabled = self.config.getboolean(
[62] Fix | Delete
'suspensions',
[63] Fix | Delete
'enabled',
[64] Fix | Delete
)
[65] Fix | Delete
self.warnings_enabled = self.config.getboolean(
[66] Fix | Delete
'warnings',
[67] Fix | Delete
'enabled',
[68] Fix | Delete
)
[69] Fix | Delete
[70] Fix | Delete
self.freepass_enabled = self.config.getboolean(
[71] Fix | Delete
'freepass',
[72] Fix | Delete
'enabled',
[73] Fix | Delete
)
[74] Fix | Delete
[75] Fix | Delete
self.actions = {
[76] Fix | Delete
'suspension': enact_suspension,
[77] Fix | Delete
'warning': send_warning,
[78] Fix | Delete
'freepass': give_free_pass,
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
self.server_overloaded = server_overloaded()
[82] Fix | Delete
[83] Fix | Delete
_users = top_users(
[84] Fix | Delete
interval_file=self.sa_interval_file,
[85] Fix | Delete
max_age=self.sa_interval_file_max_age,
[86] Fix | Delete
)
[87] Fix | Delete
[88] Fix | Delete
self.users = {
[89] Fix | Delete
name: User(
[90] Fix | Delete
name=name,
[91] Fix | Delete
delta=delta,
[92] Fix | Delete
suspensions=self.priors.get(name, {}).get('suspensions', []),
[93] Fix | Delete
warnings=self.priors.get(name, {}).get('warnings', []),
[94] Fix | Delete
freepasses=self.priors.get(name, {}).get('freepasses', []),
[95] Fix | Delete
)
[96] Fix | Delete
for name, delta in _users
[97] Fix | Delete
if not is_suspended(name)
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
def __repr__(self):
[101] Fix | Delete
"""
[102] Fix | Delete
Returns a representation of an Autosuspend object
[103] Fix | Delete
"""
[104] Fix | Delete
repr_data = [
[105] Fix | Delete
'brand',
[106] Fix | Delete
'disruptive_action_interval',
[107] Fix | Delete
'server_load_factor',
[108] Fix | Delete
'server_overloaded',
[109] Fix | Delete
'suspensions_enabled',
[110] Fix | Delete
'warnings_enabled',
[111] Fix | Delete
'freepass_enabled',
[112] Fix | Delete
]
[113] Fix | Delete
repr_str = '<Autosuspend {}>'.format(
[114] Fix | Delete
' '.join([f'{i}:{getattr(self, i)}' for i in repr_data])
[115] Fix | Delete
)
[116] Fix | Delete
return repr_str
[117] Fix | Delete
[118] Fix | Delete
def suspension_critera_met(self, user):
[119] Fix | Delete
"""
[120] Fix | Delete
Tests a User object to see if it meets suspension criteria
[121] Fix | Delete
"""
[122] Fix | Delete
if not user.warned_within(self.disruptive_action_interval):
[123] Fix | Delete
self.logger.debug(
[124] Fix | Delete
f'{user.name} not warned within {self.disruptive_action_interval}, not suspending'
[125] Fix | Delete
)
[126] Fix | Delete
return False
[127] Fix | Delete
[128] Fix | Delete
# double check this logic - if user was suspended longer ago than action_interval they should be elligible
[129] Fix | Delete
if not user.suspended_longer_ago(self.disruptive_action_interval):
[130] Fix | Delete
self.logger.debug(
[131] Fix | Delete
f'{user.name} not suspended within {self.disruptive_action_interval}, not suspending'
[132] Fix | Delete
)
[133] Fix | Delete
return False
[134] Fix | Delete
[135] Fix | Delete
if user.num_warnings <= self.warning_count:
[136] Fix | Delete
self.logger.debug(
[137] Fix | Delete
f'Not suspended; only {user.num_warnings} warnings, need {self.warning_count}'
[138] Fix | Delete
)
[139] Fix | Delete
return False
[140] Fix | Delete
[141] Fix | Delete
if float(user.delta) >= float(self.suspensions['max_delta']):
[142] Fix | Delete
return True
[143] Fix | Delete
[144] Fix | Delete
return False
[145] Fix | Delete
[146] Fix | Delete
def warning_critera_met(self, user):
[147] Fix | Delete
"""
[148] Fix | Delete
Tests a User object to see if it meets warning criteria
[149] Fix | Delete
"""
[150] Fix | Delete
[151] Fix | Delete
if user.warned_within(self.disruptive_action_interval):
[152] Fix | Delete
self.logger.debug(
[153] Fix | Delete
f'{user.name} warned within {self.disruptive_action_interval}, not warning'
[154] Fix | Delete
)
[155] Fix | Delete
return False
[156] Fix | Delete
[157] Fix | Delete
if float(user.delta) >= float(self.warnings['max_delta']):
[158] Fix | Delete
return True
[159] Fix | Delete
else:
[160] Fix | Delete
self.logger.debug(
[161] Fix | Delete
'{} has not consumed more than {}cp in the last {}'.format(
[162] Fix | Delete
user.name,
[163] Fix | Delete
self.warnings['max_delta'],
[164] Fix | Delete
self.disruptive_action_interval,
[165] Fix | Delete
)
[166] Fix | Delete
)
[167] Fix | Delete
[168] Fix | Delete
return False
[169] Fix | Delete
[170] Fix | Delete
def freepass_criteria_met(self, user):
[171] Fix | Delete
"""
[172] Fix | Delete
Tests a user to see if it meets freepass criteria
[173] Fix | Delete
"""
[174] Fix | Delete
self.logger.debug(f'Testing {user.name} for freepass...')
[175] Fix | Delete
if float(user.delta) >= float(self.freepass['max_delta']):
[176] Fix | Delete
self.logger.debug(
[177] Fix | Delete
f'{user.name} has a delta of {user.delta}, which is above the threshold.'
[178] Fix | Delete
)
[179] Fix | Delete
if not user.given_freepass_within(self.time_between_free_passes):
[180] Fix | Delete
self.logger.debug(
[181] Fix | Delete
f'{user.name} was not given a free pass within {self.time_between_free_passes} so they get one'
[182] Fix | Delete
)
[183] Fix | Delete
return True
[184] Fix | Delete
else:
[185] Fix | Delete
self.logger.debug(
[186] Fix | Delete
f'{user.name} got a free pass within the last {self.time_between_free_passes} days, not sending another'
[187] Fix | Delete
)
[188] Fix | Delete
[189] Fix | Delete
return False
[190] Fix | Delete
[191] Fix | Delete
def run(self):
[192] Fix | Delete
"""
[193] Fix | Delete
Loops through Autosuspend.users, calling Autosuspend.test for each
[194] Fix | Delete
[195] Fix | Delete
"""
[196] Fix | Delete
self.logger.info(f'Autosuspend run starting {repr(self)}')
[197] Fix | Delete
if not self.users:
[198] Fix | Delete
return
[199] Fix | Delete
[200] Fix | Delete
for user in self.users.values():
[201] Fix | Delete
action = self.test(user)
[202] Fix | Delete
action_func = self.actions.get(
[203] Fix | Delete
action,
[204] Fix | Delete
lambda *x, **y: None,
[205] Fix | Delete
)
[206] Fix | Delete
wrapper = partial(
[207] Fix | Delete
action_func, email_template=getattr(self, f'{action}_template')
[208] Fix | Delete
)
[209] Fix | Delete
[210] Fix | Delete
wrapper(user=user.name, comment=user.note)
[211] Fix | Delete
self.logger.info('Autosuspend run complete')
[212] Fix | Delete
[213] Fix | Delete
def test(self, user):
[214] Fix | Delete
"""
[215] Fix | Delete
Determines what action, if any to take against an individual
[216] Fix | Delete
User object
[217] Fix | Delete
"""
[218] Fix | Delete
user.suspend = self.suspension_critera_met(user)
[219] Fix | Delete
user.warn = self.warning_critera_met(user)
[220] Fix | Delete
user.freepass = self.freepass_criteria_met(user)
[221] Fix | Delete
[222] Fix | Delete
if user.suspend and self.suspensions_enabled and self.server_overloaded:
[223] Fix | Delete
user.note = (
[224] Fix | Delete
'AUTO SUSPENSION: Consumed {:.2f}cp within '
[225] Fix | Delete
'the last measured interval.'.format(user.delta)
[226] Fix | Delete
)
[227] Fix | Delete
self.logger.debug(f'Suspending {user}')
[228] Fix | Delete
self.logger.info(
[229] Fix | Delete
f'{user.delta} [AUTO_SUSPENSION] ra - root "{user.note}"'
[230] Fix | Delete
)
[231] Fix | Delete
return 'suspension'
[232] Fix | Delete
[233] Fix | Delete
elif user.freepass and self.freepass_enabled:
[234] Fix | Delete
user.note = (
[235] Fix | Delete
'AUTO RA FREEPASS: Consumed {:.2f}cp within '
[236] Fix | Delete
'the last measured interval.'.format(user.delta)
[237] Fix | Delete
)
[238] Fix | Delete
self.logger.debug(f'Freepassing {user}')
[239] Fix | Delete
self.logger.info(f'{user.name} [FREEPASS] ra - root "{user.note}"')
[240] Fix | Delete
return 'freepass'
[241] Fix | Delete
[242] Fix | Delete
elif user.warn and self.warnings_enabled:
[243] Fix | Delete
user.note = (
[244] Fix | Delete
'AUTO RA WARNING: Consumed {:.2f}cp within '
[245] Fix | Delete
'the last measured interval.'.format(user.delta)
[246] Fix | Delete
)
[247] Fix | Delete
self.logger.debug(f'Warning {user}')
[248] Fix | Delete
self.logger.info(f'{user.name} [WARNING] ra - root "{user.note}"')
[249] Fix | Delete
return 'warning'
[250] Fix | Delete
else:
[251] Fix | Delete
self.logger.debug(f'Skipping {user}')
[252] Fix | Delete
return 'skip'
[253] Fix | Delete
[254] Fix | Delete
def __getattr__(self, item):
[255] Fix | Delete
"""
[256] Fix | Delete
Returns items as strings from settings and brand-specific settings
[257] Fix | Delete
sections or entire config sections as a dict
[258] Fix | Delete
[259] Fix | Delete
e.g. <Autosuspend instance>.suspension_log;
[260] Fix | Delete
<Autosuspend instance>.settings['suspension_log']
[261] Fix | Delete
"""
[262] Fix | Delete
if item in self.config.sections():
[263] Fix | Delete
return dict(self.config.items(item))
[264] Fix | Delete
# See if a given key is present in the settings section
[265] Fix | Delete
for section in (f'settings_{self.brand}', 'settings'):
[266] Fix | Delete
if self.config.has_option(section, item):
[267] Fix | Delete
return self.config.get(section, item)
[268] Fix | Delete
[269] Fix | Delete
[270] Fix | Delete
class User:
[271] Fix | Delete
"""
[272] Fix | Delete
Instantiated to represent a system user.
[273] Fix | Delete
"""
[274] Fix | Delete
[275] Fix | Delete
def __init__(self, **args):
[276] Fix | Delete
"""
[277] Fix | Delete
Initializes the User object
[278] Fix | Delete
"""
[279] Fix | Delete
self.data_dict = args
[280] Fix | Delete
self.warn = False
[281] Fix | Delete
self.suspend = False
[282] Fix | Delete
self.freepass = False
[283] Fix | Delete
self.num_suspensions = len(args['suspensions'])
[284] Fix | Delete
self.num_warnings = len(args['warnings'])
[285] Fix | Delete
self.num_freepasses = len(args['freepasses'])
[286] Fix | Delete
[287] Fix | Delete
def __getattr__(self, item):
[288] Fix | Delete
"""
[289] Fix | Delete
Returns an item from self.data_dict or None in the event of a KeyError
[290] Fix | Delete
"""
[291] Fix | Delete
try:
[292] Fix | Delete
return self.data_dict[item]
[293] Fix | Delete
except KeyError:
[294] Fix | Delete
pass
[295] Fix | Delete
[296] Fix | Delete
def __repr__(self):
[297] Fix | Delete
"""
[298] Fix | Delete
Returns a useful representation of a User object
[299] Fix | Delete
"""
[300] Fix | Delete
repr_data = [
[301] Fix | Delete
'name',
[302] Fix | Delete
'delta',
[303] Fix | Delete
'last_suspension',
[304] Fix | Delete
'last_warning',
[305] Fix | Delete
'last_freepass',
[306] Fix | Delete
'num_suspensions',
[307] Fix | Delete
'num_warnings',
[308] Fix | Delete
'num_freepasses',
[309] Fix | Delete
'suspend',
[310] Fix | Delete
'warn',
[311] Fix | Delete
'freepass',
[312] Fix | Delete
'note',
[313] Fix | Delete
]
[314] Fix | Delete
[315] Fix | Delete
repr_str = '<User {}>'.format(
[316] Fix | Delete
' '.join([f'{i}:{getattr(self, i)}' for i in repr_data])
[317] Fix | Delete
)
[318] Fix | Delete
return repr_str
[319] Fix | Delete
[320] Fix | Delete
def warned_within(self, delta):
[321] Fix | Delete
"""
[322] Fix | Delete
Returns True if the user's last warning was sent within the current
[323] Fix | Delete
time - delta, False otherwise
[324] Fix | Delete
"""
[325] Fix | Delete
if not isinstance(delta, datetime.timedelta):
[326] Fix | Delete
delta = str_to_timedelta(delta)
[327] Fix | Delete
try:
[328] Fix | Delete
return datetime.datetime.now() < (self.last_warning + delta)
[329] Fix | Delete
except TypeError:
[330] Fix | Delete
return False
[331] Fix | Delete
[332] Fix | Delete
def suspended_longer_ago(self, delta):
[333] Fix | Delete
"""
[334] Fix | Delete
Returns True if the user's last suspension was longer ago
[335] Fix | Delete
than the current time - delta, False otherwise
[336] Fix | Delete
"""
[337] Fix | Delete
if not isinstance(delta, datetime.timedelta):
[338] Fix | Delete
delta = str_to_timedelta(delta)
[339] Fix | Delete
try:
[340] Fix | Delete
return datetime.datetime.now() > (self.last_suspension + delta)
[341] Fix | Delete
except TypeError:
[342] Fix | Delete
return True
[343] Fix | Delete
[344] Fix | Delete
def given_freepass_within(self, delta):
[345] Fix | Delete
"""
[346] Fix | Delete
In the case self.last_freepass is None, we return false.
[347] Fix | Delete
"""
[348] Fix | Delete
if not self.last_freepass:
[349] Fix | Delete
return False
[350] Fix | Delete
if not isinstance(delta, datetime.timedelta):
[351] Fix | Delete
delta = str_to_timedelta(delta)
[352] Fix | Delete
try:
[353] Fix | Delete
return datetime.datetime.now() < (self.last_freepass + delta)
[354] Fix | Delete
except TypeError:
[355] Fix | Delete
return True
[356] Fix | Delete
[357] Fix | Delete
@property
[358] Fix | Delete
def last_suspension(self):
[359] Fix | Delete
"""
[360] Fix | Delete
returns a datetime object which represents the last time
[361] Fix | Delete
the user was suspended or None
[362] Fix | Delete
"""
[363] Fix | Delete
return self._last_suspension
[364] Fix | Delete
[365] Fix | Delete
@last_suspension.getter
[366] Fix | Delete
def last_suspension(self):
[367] Fix | Delete
"""
[368] Fix | Delete
returns a datetime object which represents the last time
[369] Fix | Delete
the user was suspended or None
[370] Fix | Delete
"""
[371] Fix | Delete
return self._nth_date('suspensions', -1)
[372] Fix | Delete
[373] Fix | Delete
@property
[374] Fix | Delete
def last_warning(self):
[375] Fix | Delete
"""
[376] Fix | Delete
returns a datetime object which represents the last time
[377] Fix | Delete
the user was warned or None
[378] Fix | Delete
"""
[379] Fix | Delete
return self._last_warning
[380] Fix | Delete
[381] Fix | Delete
@last_warning.getter
[382] Fix | Delete
def last_warning(self):
[383] Fix | Delete
"""
[384] Fix | Delete
returns a datetime object which represents the last time
[385] Fix | Delete
the user was warned or None
[386] Fix | Delete
"""
[387] Fix | Delete
return self._nth_date('warnings', -1)
[388] Fix | Delete
[389] Fix | Delete
@property
[390] Fix | Delete
def last_freepass(self):
[391] Fix | Delete
return self._last_freepass
[392] Fix | Delete
[393] Fix | Delete
@last_freepass.getter
[394] Fix | Delete
def last_freepass(self):
[395] Fix | Delete
return self._nth_date('freepasses', -1)
[396] Fix | Delete
[397] Fix | Delete
def _nth_date(self, attr, index):
[398] Fix | Delete
"""
[399] Fix | Delete
Return a datetime object representation of a date from
[400] Fix | Delete
suspension or warning lists
[401] Fix | Delete
"""
[402] Fix | Delete
items = getattr(self, attr)
[403] Fix | Delete
try:
[404] Fix | Delete
return datetime.datetime.fromtimestamp(
[405] Fix | Delete
sorted(map(float, items))[index]
[406] Fix | Delete
)
[407] Fix | Delete
except (TypeError, IndexError):
[408] Fix | Delete
pass
[409] Fix | Delete
[410] Fix | Delete
[411] Fix | Delete
def str_to_timedelta(time_str):
[412] Fix | Delete
"""
[413] Fix | Delete
Munges strings into timedelta objects
[414] Fix | Delete
"""
[415] Fix | Delete
match = re.search(
[416] Fix | Delete
r"""(:?
[417] Fix | Delete
(:?(?P<hours>\d+)[Hh])?
[418] Fix | Delete
(:?(?P<minutes>\d+)[Mm])?
[419] Fix | Delete
(:?(?P<days>\d+)[Dd])?
[420] Fix | Delete
(:?(?P<seconds>\d+)[Ss])?
[421] Fix | Delete
)+""",
[422] Fix | Delete
''.join(time_str.split()),
[423] Fix | Delete
re.VERBOSE,
[424] Fix | Delete
)
[425] Fix | Delete
groups = {k: float(v) for k, v in match.groupdict().items() if v}
[426] Fix | Delete
return datetime.timedelta(**groups)
[427] Fix | Delete
[428] Fix | Delete
[429] Fix | Delete
def server_overloaded(factor=1.5):
[430] Fix | Delete
"""
[431] Fix | Delete
Determines whether or not the sever is unduly stressed by comparing the
[432] Fix | Delete
15-minute load average and the product of number of cores and 'factor'.
[433] Fix | Delete
"""
[434] Fix | Delete
return (cpu_count() * factor) <= os.getloadavg()[-1]
[435] Fix | Delete
[436] Fix | Delete
[437] Fix | Delete
def try_open_yaml(yaml_path):
[438] Fix | Delete
"""Try to read a yaml file. If impossible, return an empty dict"""
[439] Fix | Delete
try:
[440] Fix | Delete
data = yaml.load(file(yaml_path, 'r'))
[441] Fix | Delete
except (OSError, yaml.error.MarkedYAMLError):
[442] Fix | Delete
return {}
[443] Fix | Delete
if not isinstance(data, dict):
[444] Fix | Delete
return {}
[445] Fix | Delete
return data
[446] Fix | Delete
[447] Fix | Delete
[448] Fix | Delete
def get_log_data(logfile, offsetfile, ignore_offset=False):
[449] Fix | Delete
"""
[450] Fix | Delete
Reads and offset from the offset file, returns data from the offset to
[451] Fix | Delete
the end of the file
[452] Fix | Delete
"""
[453] Fix | Delete
[454] Fix | Delete
# try to read the offset from the offset file
[455] Fix | Delete
try:
[456] Fix | Delete
with open(offsetfile) as offset_fh:
[457] Fix | Delete
offset = int(offset_fh.readline())
[458] Fix | Delete
# Set offset to 0 if the offset can't be converted to an integer or the
[459] Fix | Delete
# file is missing
[460] Fix | Delete
except (OSError, ValueError):
[461] Fix | Delete
offset = 0
[462] Fix | Delete
[463] Fix | Delete
if ignore_offset:
[464] Fix | Delete
offset = 0
[465] Fix | Delete
[466] Fix | Delete
try:
[467] Fix | Delete
with open(logfile) as logfile_fh:
[468] Fix | Delete
logfile_fh.seek(0, 2)
[469] Fix | Delete
logfile_length = logfile_fh.tell()
[470] Fix | Delete
if offset > logfile_length:
[471] Fix | Delete
logfile_fh.seek(0)
[472] Fix | Delete
else:
[473] Fix | Delete
logfile_fh.seek(offset)
[474] Fix | Delete
output = logfile_fh.readlines()
[475] Fix | Delete
newoffset = logfile_fh.tell()
[476] Fix | Delete
# If the file can't be opened return an empty string
[477] Fix | Delete
# and set newoffset to 0
[478] Fix | Delete
except OSError:
[479] Fix | Delete
output = ""
[480] Fix | Delete
newoffset = 0
[481] Fix | Delete
[482] Fix | Delete
# Write the new offset to the offset file
[483] Fix | Delete
with open(offsetfile, 'w') as offset_fh:
[484] Fix | Delete
offset_fh.write(str(newoffset))
[485] Fix | Delete
return output
[486] Fix | Delete
[487] Fix | Delete
[488] Fix | Delete
def prior_events(log=None, log_offset=None, data_file=None):
[489] Fix | Delete
'''Returns a dict that contains account suspension times'''
[490] Fix | Delete
suspension_re = re.compile(
[491] Fix | Delete
r"""(?P<time>\d{4}-\d{2}-\d{2}:\d{2}:\d{2}:\d{2})
[492] Fix | Delete
\s\w+\s+[\w/\.-]+:\s+(?P<user>\w+)\s+\[
[493] Fix | Delete
(:?
[494] Fix | Delete
(?P<suspensions>(:?AUTO_)?SUSPENSION)|
[495] Fix | Delete
(?P<warnings>WARNING)|
[496] Fix | Delete
(?P<freepasses>FREEPASS)
[497] Fix | Delete
)
[498] Fix | Delete
\]\s+ra""",
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function