Regex not working in custom log
Posted: 16 Sep 2023, 21:24
So I'm an idiot. What can I say?
I've set my customlog1 as follows:
CUSTOM1_LOG = "/var/log/nginx/access_log"
Yes, that is the correct path.
The format looks like:
118.126.124.10 - - [16/Sep/2023:15:31:48 -0400] "HEAD /manager/html HTTP/1.1" 404 0 "-" "Python/3.6 aiohttp/3.8.3"
I'm looking for 5 404's from the same IP in the specified time period in order to give them the boot. Truthfully, if they're appearing in that log, they're not doing anything useful on the server, ie, they're not accessing any domains, so 5 is being extraordinarily generous.
My regex, which I tested on regex101.com, looks as follows:
\"\s404\s
does not appear to trigger LFD, but regex101 matches on 404.
My entry in regex.custom.pm is:
if (($globlogs{CUSTOM1_LOG}{$lgfile}) and ($line =~ \"\s404\s
{
return ("NotFound from",$1,"NotFound","5","80,443","1","0");
}
What am I missing? I'm sure I'm being stupid. I'm not all that great w/regex. Still, regex101 indicated my regex was correct, so I'm confused.
Thanks so much for any assistance. I appreciate your time.
I've set my customlog1 as follows:
CUSTOM1_LOG = "/var/log/nginx/access_log"
Yes, that is the correct path.
The format looks like:
118.126.124.10 - - [16/Sep/2023:15:31:48 -0400] "HEAD /manager/html HTTP/1.1" 404 0 "-" "Python/3.6 aiohttp/3.8.3"
I'm looking for 5 404's from the same IP in the specified time period in order to give them the boot. Truthfully, if they're appearing in that log, they're not doing anything useful on the server, ie, they're not accessing any domains, so 5 is being extraordinarily generous.
My regex, which I tested on regex101.com, looks as follows:
\"\s404\s
does not appear to trigger LFD, but regex101 matches on 404.
My entry in regex.custom.pm is:
if (($globlogs{CUSTOM1_LOG}{$lgfile}) and ($line =~ \"\s404\s
{
return ("NotFound from",$1,"NotFound","5","80,443","1","0");
}
What am I missing? I'm sure I'm being stupid. I'm not all that great w/regex. Still, regex101 indicated my regex was correct, so I'm confused.
Thanks so much for any assistance. I appreciate your time.