From 2b653733d2a6f909ec7cb92fe88788197db1a068 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 10 Feb 2022 19:25:53 +0000 Subject: [PATCH] scripts/apache-log-rate: Bug fix & misc. * Comparison had an off-by one, accidentally including "second before" still. * Print out compiled regex for matching apache lines, in case of custom request text usage. * Output the timestamp at the end of the largest window. This enables easy checking of logs for possible anomalies around then. * Comment about how apache logs *aren't* actually strictly in time-order, but we assume they are. --- scripts/apache-log-rate | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/apache-log-rate b/scripts/apache-log-rate index 65ac301..5e63280 100755 --- a/scripts/apache-log-rate +++ b/scripts/apache-log-rate @@ -25,12 +25,15 @@ def process_log_file( print(f'With:\n\tinput_file: "{input_file}"\n\trequest_text: "{request_text}"') with fileinput.FileInput(files=(input_file)) as f: apache_re = re.compile(r'^(?P[.:0-9a-fA-F]{3,39}) - - \[(?P[^\]]+)\] (?P.*' + request_text + '.*)$') + print(f'Apache RE:\n{apache_re}\n') apache_datetime_re = re.compile( r'^(?P[0-9]{2})/(?P[^/]{3})/(?P[0-9]{4}):(?P