]> arthur.barton.de Git - netdata.git/commitdiff
fail2ban_plugin: parse both conf_path and conf_dir/; regex update
authorIlya <ilyamaschenko@gmail.com>
Fri, 24 Feb 2017 11:59:40 +0000 (20:59 +0900)
committerIlya <ilyamaschenko@gmail.com>
Fri, 24 Feb 2017 11:59:40 +0000 (20:59 +0900)
python.d/fail2ban.chart.py

index 85ac2d43fae274f1959624d3dfa14ad91f1e2cb2..c7d24e8c15db195dd567024830646e02b54a7f6d 100644 (file)
@@ -15,7 +15,7 @@ from glob import glob
 
 priority = 60000
 retries = 60
-REGEX = compile(r'\[([A-Za-z-]+)][^\[\]]*? enabled = true')
+REGEX = compile(r'\[([A-Za-z-_]+)][^\[\]]*?(?<!# )enabled = true')
 ORDER = ['jails_group']
 
 
@@ -65,14 +65,19 @@ class Service(LogService):
         if not is_accessible(self.log_path, R_OK):
             self.error('Cannot access file %s' % self.log_path)
             return False
+        jails_list = list()
 
         if self.conf_dir:
-            jails_list, error = parse_conf_dir(self.conf_dir)
-        else:
-            jails_list, error = parse_conf_path(self.conf_path)
-
-        if not jails_list:
-            self.error(error)
+            dir_jails, error = parse_conf_dir(self.conf_dir)
+            jails_list.extend(dir_jails)
+            if not dir_jails:
+                self.error(error)
+
+        if self.conf_path:
+            path_jails, error = parse_conf_path(self.conf_path)
+            jails_list.extend(path_jails)
+            if not path_jails:
+                self.error(error)
 
         # If for some reason parse failed we still can START with default jails_list.
         self.jails_list = list(set(jails_list) - set(self.exclude)) or ['ssh']