diff options
author | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:45 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:45 +0000 |
commit | 7ee3962eaca4214264964ae32c86de457a90e382 (patch) | |
tree | 5a784485351593ac6d74fa9fd9bbd8fe7c9c3fe0 /python.d/fail2ban.chart.py | |
parent | maintscript eludes me (diff) | |
parent | New upstream version 1.8.0+dfsg (diff) | |
download | netdata-7ee3962eaca4214264964ae32c86de457a90e382.tar.xz netdata-7ee3962eaca4214264964ae32c86de457a90e382.zip |
Updated version 1.8.0+dfsg from 'upstream/1.8.0+dfsg'
with Debian dir 412de09d9bca38fe00146ef090f9e53f76493882
Diffstat (limited to 'python.d/fail2ban.chart.py')
-rw-r--r-- | python.d/fail2ban.chart.py | 9 |
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) |