From 6aaf5ba7ed0980c14bdc554fc8839a2126455ed5 Mon Sep 17 00:00:00 2001 From: Lennart Weller Date: Mon, 18 Sep 2017 00:17:33 +0200 Subject: New upstream version 1.8.0+dfsg --- python.d/fail2ban.chart.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'python.d/fail2ban.chart.py') 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]+)][^\[\]]*?(?[A-Za-z-_0-9]+)\] (?P(?:(U|B)))[a-z]+ (?P\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[A-Za-z-_0-9]+)\] (?PU|B)[a-z]+ (?P\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) -- cgit v1.2.3