Skip to content

Instantly share code, notes, and snippets.

@kwirk
Created April 16, 2013 17:18
Show Gist options
  • Save kwirk/5397732 to your computer and use it in GitHub Desktop.
Save kwirk/5397732 to your computer and use it in GitHub Desktop.
fail2ban Apache Tomcat date format
diff --git a/server/datedetector.py b/server/datedetector.py
index a54e072..2976450 100644
--- a/server/datedetector.py
+++ b/server/datedetector.py
@@ -161,6 +161,12 @@ class DateDetector:
template.setRegex("^\d{2}\d{2}\d{2} +\d{1,2}:\d{2}:\d{2}")
template.setPattern("%y%m%d %H:%M:%S")
self._appendTemplate(template)
+ # Apache Tomcat
+ template = DateStrptime()
+ template.setName("MONTH Day, Year 12hour:Minute:Second AM/PM")
+ template.setRegex("\S{3}\s{1,2}\d{1,2}, \d{4} \d{1,2}:\d{2}:\d{2} [AP]M")
+ template.setPattern("%b %d, %Y %I:%M:%S %p")
+ self._appendTemplate(template)
finally:
self.__lock.release()
diff --git a/testcases/datedetectortestcase.py b/testcases/datedetectortestcase.py
index 7c3c714..932aa21 100644
--- a/testcases/datedetectortestcase.py
+++ b/testcases/datedetectortestcase.py
@@ -85,6 +85,7 @@ class DateDetectorTest(unittest.TestCase):
"2005-01-23T21:59:59-05:00Z", #ISO 8601 with TZ
"<01/23/05@21:59:59>",
"050123 21:59:59", # MySQL
+ "Jan 23, 2005 9:59:59 PM", # Apache Tomcat
):
log = sdate + "[sshd] error: PAM: Authentication failure"
# exclude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment