@cryptotaxi247 / netdata-1 / commits / 6b4ed885f

fail2ban_plugin: parse both conf_path and conf_dir/; regex update

Ilya committed Feb 24, 2017 at 20:59 UTC 6b4ed885fc3e86ed009a8ea877f8a8ef3fc6610a
1 file changed +12 -7
python.d/fail2ban.chart.py
+12 -7
@@ -15,7 +15,7 @@ from glob import glob
15
16 priority = 60000
17 retries = 60
18 -REGEX = compile(r'\[([A-Za-z-]+)][^\[\]]*? enabled = true')
18 +REGEX = compile(r'\[([A-Za-z-_]+)][^\[\]]*?(?<!# )enabled = true')
19 ORDER = ['jails_group']
20
21
@@ -65,14 +65,19 @@ class Service(LogService):
65 if not is_accessible(self.log_path, R_OK):
66 self.error('Cannot access file %s' % self.log_path)
67 return False
68 + jails_list = list()
69
70 if self.conf_dir:
70 - jails_list, error = parse_conf_dir(self.conf_dir)
71 - else:
72 - jails_list, error = parse_conf_path(self.conf_path)
73 -
74 - if not jails_list:
75 - self.error(error)
71 + dir_jails, error = parse_conf_dir(self.conf_dir)
72 + jails_list.extend(dir_jails)
73 + if not dir_jails:
74 + self.error(error)
75 +
76 + if self.conf_path:
77 + path_jails, error = parse_conf_path(self.conf_path)
78 + jails_list.extend(path_jails)
79 + if not path_jails:
80 + self.error(error)
81
82 # If for some reason parse failed we still can START with default jails_list.
83 self.jails_list = list(set(jails_list) - set(self.exclude)) or ['ssh']