fail2ban fix: add 'Restore Ban' action (#4772)
* fail2ban fix: add 'Restore Ban' action * fail2ban fix: get_data early return fix
Ilya Mashchenko committed
Nov 28, 2018 at 13:10 UTC
ac55ecf701dd8992e50c3ae5812e6f3d06b6f417
1 file changed
+4
-3
collectors/python.d.plugin/fail2ban/fail2ban.chart.py
+4
-3
@@ -46,7 +46,8 @@ RE_JAILS = re.compile(r'\[([a-zA-Z0-9_-]+)\][^\[\]]+?enabled\s+= (true|false)')
46
# Example:
47
# 2018-09-12 11:45:53,715 fail2ban.actions[25029]: WARNING [ssh] Unban 195.201.88.33
48
# 2018-09-12 11:45:58,727 fail2ban.actions[25029]: WARNING [ssh] Ban 217.59.246.27
49
-RE_DATA = re.compile(r'\[(?P<jail>[A-Za-z-_0-9]+)\] (?P<action>Unban|Ban) (?P<ip>[a-f0-9.:]+)')
49
+# 2018-09-12 11:45:58,727 fail2ban.actions[25029]: WARNING [ssh] Restore Ban 217.59.246.27
50
+RE_DATA = re.compile(r'\[(?P<jail>[A-Za-z-_0-9]+)\] (?P<action>Unban|Ban|Restore Ban) (?P<ip>[a-f0-9.:]+)')
51
52
DEFAULT_JAILS = [
53
'ssh',
@@ -116,7 +117,7 @@ class Service(LogService):
117
118
jail, action, ip = match['jail'], match['action'], match['ip']
119
119
- if action == 'Ban':
120
+ if action == 'Ban' or action == 'Restore Ban':
121
self.data[jail] += 1
122
if ip not in self.banned_ips[jail]:
123
self.banned_ips[jail].add(ip)
@@ -126,7 +127,7 @@ class Service(LogService):
127
self.banned_ips[jail].remove(ip)
128
self.data['{0}_in_jail'.format(jail)] -= 1
129
129
- return self.data
130
+ return self.data
131
132
def get_files_from_dir(self, dir_path, suffix):
133
"""