summaryrefslogtreecommitdiffstats
path: root/python.d/fail2ban.chart.py
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2017-09-17 22:17:33 +0000
committerLennart Weller <lhw@ring0.de>2017-09-17 22:17:33 +0000
commit6aaf5ba7ed0980c14bdc554fc8839a2126455ed5 (patch)
tree6161925716661486e7f47c479668a9487b039d83 /python.d/fail2ban.chart.py
parentNew upstream version 1.7.0+dfsg (diff)
downloadnetdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.tar.xz
netdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.zip
New upstream version 1.8.0+dfsgupstream/1.8.0+dfsg
Diffstat (limited to 'python.d/fail2ban.chart.py')
-rw-r--r--python.d/fail2ban.chart.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/python.d/fail2ban.chart.py b/python.d/fail2ban.chart.py
index 35761e894..5238fa16e 100644
--- a/python.d/fail2ban.chart.py
+++ b/python.d/fail2ban.chart.py
@@ -11,8 +11,8 @@ from base import LogService
priority = 60000
retries = 60
-REGEX_JAILS = r_compile(r'\[([A-Za-z-_0-9]+)][^\[\]]*?(?<!# )enabled = (?:(true|false))')
-REGEX_DATA = r_compile(r'\[(?P<jail>[A-Za-z-_0-9]+)\] (?P<action>(?:(U|B)))[a-z]+ (?P<ipaddr>\d{1,3}(?:\.\d{1,3}){3})')
+REGEX_JAILS = r_compile(r'\[([a-zA-Z0-9_-]+)\][^\[\]]+?enabled\s+= (true|false)')
+REGEX_DATA = r_compile(r'\[(?P<jail>[A-Za-z-_0-9]+)\] (?P<action>U|B)[a-z]+ (?P<ipaddr>\d{1,3}(?:\.\d{1,3}){3})')
ORDER = ['jails_bans', 'jails_in_jail']
@@ -98,7 +98,6 @@ class Service(LogService):
jails_list.append(jail)
elif status == 'false' and jail in jails_list:
jails_list.remove(jail)
-
# If for some reason parse failed we still can START with default jails_list.
jails_list = list(set(jails_list) - set(self.exclude.split()
if isinstance(self.exclude, str) else list())) or ['ssh']
@@ -182,8 +181,8 @@ def find_jails_in_files(list_of_files, print_error):
for conf in list_of_files:
if is_accessible(conf, R_OK):
with open(conf, 'rt') as conf:
- raw_data = conf.read()
- data = ' '.join(raw_data.split())
+ raw_data = conf.readlines()
+ data = ' '.join(line for line in raw_data if line.startswith(('[', 'enabled')))
jails_list.extend(REGEX_JAILS.findall(data))
else:
print_error('%s is not readable or not exist' % conf)