This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit f3f3cce29588303eae317ae6248cbf22a65e69eb Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Apr 14 17:52:22 2015 +0200 detection modules loaded with connection multi compatibility --- app/module_loader.py | 33 +++++++++++----------- app/modules/detection_modules/drive_detection.py | 1 + app/modules/detection_modules/kernel_detection.py | 1 + .../detection_modules/open_ports_detection.py | 1 + app/modules/detection_modules/os_detection.py | 1 + app/modules/monitoring_modules/cpu_glances.py | 2 +- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index 8edee4d..d375330 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -150,6 +150,7 @@ class ModuleLoader: loaded_mod = __import__("modules.detection_modules." + mod_name, fromlist=[mod_name]) infos_mod = {} infos_mod['imported'] = loaded_mod + infos_mod['compatible_conn'] = getattr(loaded_mod, 'connection') infos_mod['compatible_os'] = getattr(loaded_mod, 'compatible_os') for os in infos_mod['compatible_os']: if os not in self.compatible_os_list: @@ -164,16 +165,18 @@ class ModuleLoader: :param addr_host: the IP address of the host we want to run the detection """ db = self.get_db() - conn = self.create_connection(addr_host) - if conn is not None: - for mod_name in self.loaded_mod_detect: - try: - getattr(self.loaded_mod_detect[mod_name]['imported'], - 'run_detection')(conn, db) - except modules.ModuleNotCompatibleException.ModuleNotCompatibleException as mnce: - print mnce.__str__() - except modules.CommandNotFoundException.CommandNotFoundException as cnfe: - print cnfe.__str__() + conf_conn = self.db.get_conf_conn(addr_host) + for mod_name in self.loaded_mod_detect: + for i in range(len(conf_conn)): + if self.loaded_mod_detect[mod_name]['compatible_conn'] == conf_conn[i]['conn_mod_name']: + try: + conn_inst = self.create_connection(addr_host, conf_conn[i]) + getattr(self.loaded_mod_detect[mod_name]['imported'], + 'run_detection')(conn_inst, db) + except modules.ModuleNotCompatibleException.ModuleNotCompatibleException as mnce: + print mnce.__str__() + except modules.CommandNotFoundException.CommandNotFoundException as cnfe: + print cnfe.__str__() def load_all_monitoring_modules(self): """ @@ -194,15 +197,12 @@ class ModuleLoader: if mod_name not in self.loaded_mod_moni[part]['modules']: self.loaded_mod_moni[part]['modules'][mod_name] = {} self.loaded_mod_moni[part]['modules'][mod_name]['imported'] = loaded_mod - #self.loaded_mod_moni[part]['modules'][mod_name]['conn'] = getattr(loaded_mod, 'connection') self.loaded_mod_moni[part]['modules'][mod_name]['external'] = False self.loaded_mod_moni[part]['compatible_os'] = \ list(set(self.loaded_mod_moni[part]['compatible_os'] + getattr(loaded_mod, 'compatible_os'))) self.loaded_mod_moni[part]['compatible_conn'].append(getattr(loaded_mod, 'connection')) self.loaded_mod_moni[part]['compatible_conn'] = \ list(set(self.loaded_mod_moni[part]['compatible_conn'])) - #self.loaded_mod_moni[part]['block'] = getattr(loaded_mod, 'block') - #self.loaded_mod_moni[part]['unit'] = getattr(loaded_mod, 'unit') all_internal_mod[mod_name] = part except AttributeError: print "Error : internal monitoring module " + mod_name + " could not have been loaded. " @@ -230,9 +230,6 @@ class ModuleLoader: self.loaded_mod_moni[part]['compatible_os'] = \ list(set(self.loaded_mod_moni[part]['compatible_os'] + getattr(loaded_mod, 'compatible_os'))) - #infos_mod['block'] = getattr(loaded_mod, 'block') - #infos_mod['unit'] = getattr(loaded_mod, 'unit') - #infos_mod['conn'] = getattr(loaded_mod, 'connection') self.loaded_mod_moni[part]['modules'][mod_name]['external'] = True except AttributeError: print "Error : external monitoring module " + mod_name + " could not have been loaded. " @@ -272,6 +269,10 @@ class ModuleLoader: except modules.CommandNotFoundException.CommandNotFoundException as cnfe: print cnfe.__str__() process_monitoring.remove_to_waiting_list(addr_host, part_name) + except Exception: + print "Monitoring module " + part_name + " have been disabled on " + addr_host + \ + " because of an unexpected error." + process_monitoring.remove_to_waiting_list(addr_host, part_name) def get_monitoring_modules_list(self): """ diff --git a/app/modules/detection_modules/drive_detection.py b/app/modules/detection_modules/drive_detection.py index fe69896..2f34fce 100644 --- a/app/modules/detection_modules/drive_detection.py +++ b/app/modules/detection_modules/drive_detection.py @@ -2,6 +2,7 @@ __author__ = 'aguilbaud' import json compatible_os = ['linux', 'unix'] +connection = "ssh" def run_detection(conn, db): diff --git a/app/modules/detection_modules/kernel_detection.py b/app/modules/detection_modules/kernel_detection.py index 868d657..d6058fe 100644 --- a/app/modules/detection_modules/kernel_detection.py +++ b/app/modules/detection_modules/kernel_detection.py @@ -2,6 +2,7 @@ __author__ = 'aguilbaud' import json compatible_os = ['linux', 'unix'] +connection = "ssh" def run_detection(conn, db): diff --git a/app/modules/detection_modules/open_ports_detection.py b/app/modules/detection_modules/open_ports_detection.py index fd04321..292c9ed 100644 --- a/app/modules/detection_modules/open_ports_detection.py +++ b/app/modules/detection_modules/open_ports_detection.py @@ -2,6 +2,7 @@ __author__ = 'aguilbaud' import json compatible_os = ['linux', 'unix'] +connection = "ssh" def run_detection(conn, db): diff --git a/app/modules/detection_modules/os_detection.py b/app/modules/detection_modules/os_detection.py index 420594f..ea54a60 100644 --- a/app/modules/detection_modules/os_detection.py +++ b/app/modules/detection_modules/os_detection.py @@ -3,6 +3,7 @@ import json compatible_os = ['linux', 'unix'] +connection = "ssh" def run_detection(conn, db): dict_total = {} diff --git a/app/modules/monitoring_modules/cpu_glances.py b/app/modules/monitoring_modules/cpu_glances.py index 7b07f43..a16ac18 100644 --- a/app/modules/monitoring_modules/cpu_glances.py +++ b/app/modules/monitoring_modules/cpu_glances.py @@ -27,4 +27,4 @@ def check(conn, db, mnce): ) raise exception_inst res_cpu = max(user_cpu_charge, system_cpu_charge) - return db.add_check(conn.get_addr_host(), 'cpu', 74.0) \ No newline at end of file + return db.add_check(conn.get_addr_host(), 'cpu', res_cpu) \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.