branch develop updated (22b4a74 -> 46c28b3)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository mum. See http://git.chorem.org/mum.git from 22b4a74 problème de conflit au niveau des dépendances résolu (mais filtre sur les groupes ne passe plus) new 46c28b3 - module_loader est dorénavant une classe - l'emplacement de la bdd et des modules externes sont configurables dans le fichier conf.txt The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 46c28b3325adb6546479c5772e364d433dbf8454 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 6 10:49:29 2015 +0100 - module_loader est dorénavant une classe - l'emplacement de la bdd et des modules externes sont configurables dans le fichier conf.txt Summary of changes: app/app.py | 43 ++-- app/module_loader.py | 398 ++++++++++++++++--------------- app/modules/storage_modules/shelve_db.py | 11 +- app/process_monitoring.py | 26 +- conf.txt | 2 +- static/js/controllers/groupCtrl.js | 10 +- views/groups.html | 2 +- 7 files changed, 251 insertions(+), 241 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 46c28b3325adb6546479c5772e364d433dbf8454 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 6 10:49:29 2015 +0100 - module_loader est dorénavant une classe - l'emplacement de la bdd et des modules externes sont configurables dans le fichier conf.txt --- app/app.py | 43 ++-- app/module_loader.py | 398 ++++++++++++++++--------------- app/modules/storage_modules/shelve_db.py | 11 +- app/process_monitoring.py | 26 +- conf.txt | 2 +- static/js/controllers/groupCtrl.js | 10 +- views/groups.html | 2 +- 7 files changed, 251 insertions(+), 241 deletions(-) diff --git a/app/app.py b/app/app.py index 0a1a197..038f406 100755 --- a/app/app.py +++ b/app/app.py @@ -7,7 +7,7 @@ from bottle_websocket import GeventWebSocketServer from bottle_websocket import websocket import json import threading -import module_loader +from module_loader import ModuleLoader import process_monitoring from modules.notification_modules.websocket_container import WebSocketContainer @@ -28,21 +28,23 @@ BROWSER_NOTIFICATION = "31" ERROR = "40" -wsc = WebSocketContainer +wsc = None +ml = None # Pour lancer la detection nmap avec un nouveau thread class ThreadDetect(threading.Thread): - def __init__(self, param, opt, ws): + def __init__(self, param, opt, ml, ws): threading.Thread.__init__(self) - self.param = param - self.opt = opt - self.ws = ws + self.param = param # ip_range or hostname + self.opt = opt # nmap options + self.ml = ml # module_loader + self.ws = ws # websocket connection def run(self): - db = module_loader.load_db() - scanned_ip = module_loader.run_nmap_detection(self.param, self.opt, db, self.ws, - module_loader.get_conection_modules_list(), - module_loader.get_info_mod_monitoring()) + db = self.ml.get_db() + scanned_ip = self.ml.run_nmap_detection(self.param, self.opt, db, self.ws, + self.ml.get_conection_modules_list(), + self.ml.get_info_mod_monitoring()) if scanned_ip is not None: self.ws.send(json.dumps({SUCCESS_MODULE: scanned_ip})) for ip in json.loads(scanned_ip): @@ -63,8 +65,8 @@ class ThreadDetect(threading.Thread): # Lancement de la detection apres reception d'une plage d'ip -def start_first_detection(args, ws): - t = ThreadDetect(args['ip_range'], args['nmap_options'], ws) +def start_first_detection(args, ml, ws): + t = ThreadDetect(args['ip_range'], args['nmap_options'], ml, ws) t.start() @route('/') @@ -132,6 +134,7 @@ def bower_files(filepath): # Creation d'une websocket pour permettre la communication avec le client @get('/websocket', apply=[websocket]) def receive(ws): + global ml wsc.add_websocket(ws) while True: try: @@ -140,17 +143,15 @@ def receive(ws): msg = json.loads(response) for code in msg: if code == NMAP_SCAN_DEMAND: - start_first_detection(msg[NMAP_SCAN_DEMAND], ws) + start_first_detection(msg[NMAP_SCAN_DEMAND], ml, ws) elif code == GET_HOSTS_DEMAND: - db = module_loader.load_db() + db = ml.get_db() ws.send(json.dumps({GET_HOSTS_RESPONSE: db.get_hosts()})) - del db elif code == HOST_INFO_DEMAND: - db = module_loader.load_db() + db = ml.get_db() ws.send(json.dumps({INFO_HOST: db.get_host_informations(msg[HOST_INFO_DEMAND])})) - del db elif code == CALL_FUNC_DB: - res = module_loader.launch_db_function(msg[CALL_FUNC_DB]) + res = ml.launch_db_function(msg[CALL_FUNC_DB]) if res is not None: ws.send(json.dumps({RES_CALL_FUNC_DB: res})) else: @@ -164,8 +165,10 @@ def receive(ws): # Lancement du serveur a l'adresse 0.0.0.0:1337 if __name__ == '__main__': + global ml global wsc - wsc = WebSocketContainer(module_loader.load_db()) - #process_monitoring.init(module_loader.load_db(), wsc) + ml = ModuleLoader() + wsc = WebSocketContainer(ml.get_db()) + process_monitoring.init(ml, wsc) port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) \ No newline at end of file diff --git a/app/module_loader.py b/app/module_loader.py index 086da36..4a00f9a 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -13,101 +13,149 @@ import re import pkgutil import sys -""" -Loads dynamically modules from packages connection_modules, detection_modules, monitoring_modules, storage_modules. -""" - -def load_db(): - """ - Creates an instance of the class shelve_db from storage_modules. - :return: an instance of the shelve_db class - """ - db_name = "shelve_db" - db = __import__("modules.storage_modules." + db_name, fromlist=modules.storage_modules) - db_instance = getattr(db, db_name)() - return db_instance - - -def run_nmap_detection(param, opt, db, ws, list_mod_conn, dict_mod_monitoring): - """ - Instanciates the nmap_detection module from detection_modules, and runs the detection. - :param param: parameter to put in nmap command. can be a hostname, a ip address or a ip range - :param db: an instance of a database module - :param ws: a websocket connection - :return: a list containing the IP adresses checked - """ - nmap_mod = __import__("modules.detection_modules.nmap_detection", fromlist=modules.detection_modules) - nmap_mod_instance = getattr(nmap_mod, "nmap_detection")(opt, db, ws, list_mod_conn, dict_mod_monitoring, - modules.HostNotFoundException) - try: - if re.search('^\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?$', param): - ip_range = nmap_mod_instance.check_ip_range(param) - else: - ip_range = nmap_mod_instance.launch_detection_with_hostname(param) - return ip_range - except modules.HostNotFoundException.HostNotFoundException as hnfe: - print hnfe.__str__() - ws.send(json.dumps({"40": hnfe.__str__()})) - return None - - -def load_conn(conn_name, addr_host, username, key_location): # /home/aguilbaud/.ssh/id_rsa - """ - Instanciates and creates a connection with a connection module. - :param conn_name: the name of the detection module - :param addr_host: the IP adress of the host we want to create a connection - :param key_location: the location of the public key - :return: the instance of connection module created - """ - conn = __import__("modules.connection_modules." + conn_name, fromlist=modules.connection_modules) - conn_instance = getattr(conn, conn_name)(addr_host, username, key_location, modules.CommandNotFoundException) - return conn_instance - - -def run_all_detection_modules(os, conn, db, ws): - """ - Instanciates and runs every detection_modules listed in the __init__.py file of the package corresponding to - the operating system entered in parameters. - :param os: the oprating system of the host - :param conn: an instance of a connection module - :param db: an instance of a storage module - :param ws: a websocket connection if the function have been called from a client. Is None otherwise - """ - __import__("modules.detection_modules." + os) - pack_mod_os = __import__("modules.detection_modules." + os, fromlist=modules.detection_modules.__all__) - for mod_name in pack_mod_os.__all__: - mod = __import__ ("modules.detection_modules." + os + "." + mod_name, fromlist=modules.detection_modules.unix.__all__) # on charge le module - mod_instance = getattr(mod, mod_name)(conn, db) # on appelle le constructeur +class ModuleLoader: + """ + Loads dynamically modules from packages connection_modules, detection_modules, monitoring_modules, storage_modules. + """ + def __init__(self): + fconf = open('conf.txt') + dict_conf = {} + for line in fconf.read().splitlines(): + fields = line.split('=') + dict_conf[fields[0]] = fields[1] + self.db_loc = dict_conf['db_location'] + self.external_mod_loc = dict_conf['external_modules_location'] + self.db = self.load_db() + + def load_db(self): + """ + Creates an instance of the class shelve_db from storage_modules. + :return: an instance of the shelve_db class + """ + db_name = "shelve_db" + db = __import__("modules.storage_modules." + db_name, fromlist=modules.storage_modules) + db_instance = getattr(db, db_name)(self.db_loc) + return db_instance + + def get_db(self): + return self.db + + def run_nmap_detection(self, param, opt, db, ws, list_mod_conn, dict_mod_monitoring): + """ + Instanciates the nmap_detection module from detection_modules, and runs the detection. + :param param: parameter to put in nmap command. can be a hostname, a ip address or a ip range + :param db: an instance of a database module + :param ws: a websocket connection + :return: a list containing the IP adresses checked + """ + nmap_mod = __import__("modules.detection_modules.nmap_detection", fromlist=modules.detection_modules) + nmap_mod_instance = getattr(nmap_mod, "nmap_detection")(opt, db, ws, list_mod_conn, dict_mod_monitoring, + modules.HostNotFoundException) try: - mod_instance.run_detection() - except modules.CommandNotFoundException.CommandNotFoundException as cnfe: - print cnfe.__str__() - if ws is not None: - ws.send(json.dumps({"40": cnfe.__str__()})) - - -def run_all_monitoring_modules():#os, conn, db, ws): - """ - Instanciates and runs every monitoring_modules listed in the __init__.py file of the package corresponding to - the operating system entered in parameters. - :param os: the oprating system of the host - :param conn: an instance of a connection module - :param db: an instance of a storage module - :param ws: a websocket connection if the function have been called from a client. Is None otherwise - """ - mod_list = [] - for importer, package_name, _ in pkgutil.iter_modules(["modules/monitoring_modules/"]): - full_package_name = "modules/monitoring_modules." + package_name - if full_package_name not in sys.modules: + if re.search('^\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?$', param): + ip_range = nmap_mod_instance.check_ip_range(param) + else: + ip_range = nmap_mod_instance.launch_detection_with_hostname(param) + return ip_range + except modules.HostNotFoundException.HostNotFoundException as hnfe: + print hnfe.__str__() + ws.send(json.dumps({"40": hnfe.__str__()})) + return None + + + def load_conn(self, conn_name, addr_host, username, key_location): # /home/aguilbaud/.ssh/id_rsa + """ + Instanciates and creates a connection with a connection module. + :param conn_name: the name of the detection module + :param addr_host: the IP adress of the host we want to create a connection + :param key_location: the location of the public key + :return: the instance of connection module created + """ + conn = __import__("modules.connection_modules." + conn_name, fromlist=modules.connection_modules) + conn_instance = getattr(conn, conn_name)(addr_host, username, key_location, modules.CommandNotFoundException) + return conn_instance + + + def run_all_detection_modules(self, os, conn, db, ws): + """ + Instanciates and runs every detection_modules listed in the __init__.py file of the package corresponding to + the operating system entered in parameters. + :param os: the oprating system of the host + :param conn: an instance of a connection module + :param db: an instance of a storage module + :param ws: a websocket connection if the function have been called from a client. Is None otherwise + """ + __import__("modules.detection_modules." + os) + pack_mod_os = __import__("modules.detection_modules." + os, fromlist=modules.detection_modules.__all__) + for mod_name in pack_mod_os.__all__: + mod = __import__ ("modules.detection_modules." + os + "." + mod_name, fromlist=modules.detection_modules.unix.__all__) # on charge le module + mod_instance = getattr(mod, mod_name)(conn, db) # on appelle le constructeur + try: + mod_instance.run_detection() + except modules.CommandNotFoundException.CommandNotFoundException as cnfe: + print cnfe.__str__() + if ws is not None: + ws.send(json.dumps({"40": cnfe.__str__()})) + + + def run_all_monitoring_modules(self):#os, conn, db, ws): + """ + Instanciates and runs every monitoring_modules listed in the __init__.py file of the package corresponding to + the operating system entered in parameters. + :param os: the oprating system of the host + :param conn: an instance of a connection module + :param db: an instance of a storage module + :param ws: a websocket connection if the function have been called from a client. Is None otherwise + """ + mod_list = [] + for importer, package_name, _ in pkgutil.iter_modules(["modules/monitoring_modules/"]): + full_package_name = "modules/monitoring_modules." + package_name mod = importer.find_module(package_name).load_module(full_package_name) mod_list.append(mod) - return mod_list - -""" - __import__("modules.monitoring_modules." + os) - pack_mod_os = __import__("modules.monitoring_modules." + os, fromlist=modules.monitoring_modules.__all__) - for mod_name in pack_mod_os.__all__: - mod = __import__("modules.monitoring_modules." + os + "." + mod_name, fromlist=modules.monitoring_modules.unix.__all__) # on charge le module + return mod_list + + """ + __import__("modules.monitoring_modules." + os) + pack_mod_os = __import__("modules.monitoring_modules." + os, fromlist=modules.monitoring_modules.__all__) + for mod_name in pack_mod_os.__all__: + mod = __import__("modules.monitoring_modules." + os + "." + mod_name, fromlist=modules.monitoring_modules.unix.__all__) # on charge le module + mod_instance = getattr(mod, mod_name)(conn, db, modules.ModuleNotCompatibleException) # on appelle le constructeur + try: + mod_instance.check() + except modules.ModuleNotCompatibleException.ModuleNotCompatibleException as mnce: + print mnce.__str__() + if ws is not None: + ws.send(json.dumps({"40": mnce.__str__()})) + except modules.CommandNotFoundException.CommandNotFoundException as cnfe: + print cnfe.__str__() + if ws is not None: + ws.send(json.dumps({"40": cnfe.__str__()})) + """ + + + def run_one_monitoring_module(self, mod_name, addr_host, os, conn, db, ws): + """ + Instanciates and runs one monitoring_module of the package corresponding to + the operating system entered in parameters. + :param mod_name: the name of the monitoring_module to run + :param os: the oprating system of the host + :param conn: an instance of a connection module + :param db: an instance of a storage module + :param ws: a websocket connection if the function have been called from a client. Is None otherwise + """ + if db is None: + db = self.get_db() + if conn is None: + if os is None and mod_name == 'ping': + # in this case, the connection have not been configurated yet, so we just launch a ping check + ping_mod = __import__("modules.monitoring_modules.ping", fromlist=modules.monitoring_modules.special_modules) + ping_mod_inst = getattr(ping_mod, "ping")(db, addr_host) + ping_mod_inst.check() + """ + else: + conn = load_conn("ssh", addr_host, "aguilbaud", "/home/aguilbaud/.ssh/id_rsa") + __import__("modules.monitoring_modules." + os) + mod = __import__("modules.monitoring_modules." + os + "." + mod_name, fromlist=modules.monitoring_modules.unix.__all__) mod_instance = getattr(mod, mod_name)(conn, db, modules.ModuleNotCompatibleException) # on appelle le constructeur try: mod_instance.check() @@ -119,108 +167,70 @@ def run_all_monitoring_modules():#os, conn, db, ws): print cnfe.__str__() if ws is not None: ws.send(json.dumps({"40": cnfe.__str__()})) -""" - - -def run_one_monitoring_module(mod_name, addr_host, os, conn, db, ws): - """ - Instanciates and runs one monitoring_module of the package corresponding to - the operating system entered in parameters. - :param mod_name: the name of the monitoring_module to run - :param os: the oprating system of the host - :param conn: an instance of a connection module - :param db: an instance of a storage module - :param ws: a websocket connection if the function have been called from a client. Is None otherwise - """ - if db is None: - db = load_db() - if conn is None: - if os is None and mod_name == 'ping': - # in this case, the connection have not been configurated yet, so we just launch a ping check - ping_mod = __import__("modules.monitoring_modules.ping", fromlist=modules.monitoring_modules.special_modules) - ping_mod_inst = getattr(ping_mod, "ping")(db, addr_host) - ping_mod_inst.check() -""" - else: - conn = load_conn("ssh", addr_host, "aguilbaud", "/home/aguilbaud/.ssh/id_rsa") - __import__("modules.monitoring_modules." + os) - mod = __import__("modules.monitoring_modules." + os + "." + mod_name, fromlist=modules.monitoring_modules.unix.__all__) - mod_instance = getattr(mod, mod_name)(conn, db, modules.ModuleNotCompatibleException) # on appelle le constructeur - try: - mod_instance.check() - except modules.ModuleNotCompatibleException.ModuleNotCompatibleException as mnce: - print mnce.__str__() - if ws is not None: - ws.send(json.dumps({"40": mnce.__str__()})) - except modules.CommandNotFoundException.CommandNotFoundException as cnfe: - print cnfe.__str__() - if ws is not None: - ws.send(json.dumps({"40": cnfe.__str__()})) -""" - - -def get_info_mod_monitoring(): - """ - Get information about the output and block of the monitoring modules. These informations must be written by the - module developper on the __init__.py file (add on info_mod dictionnary). - :return: a dictionary containing these informations on the form : - {'os:{ - mod_name: {'block': val, 'unit': 'bool' or '%' or unit_name} - } - } - """ - info_mods = {} - for os in modules.monitoring_modules.__all__: - package = __import__("modules.monitoring_modules." + os, fromlist=modules.monitoring_modules.__all__) - info_mods[os] = package.info_mod - return info_mods - - -def get_conection_modules_list(): - """ - Get a list containing the names of the different connection modules declared on the __init__.py file - of the connection_modules package. - :return: a list containing the names of the different connection modules declared on the __init__.py file - of the connection_modules package. - """ - pack_conn_os = __import__("modules.connection_modules", fromlist=modules.connection_modules.__all__) - return pack_conn_os.__all__ - - -def create_global_conf(db): - """ - Asks the database to create a global configuration in function of the monitoring modules descibed on the __init__.py - :param db: the database instance """ - dict_mod = {} - for os in modules.monitoring_modules.__all__: - dict_mod[os] = get_info_mod_monitoring() - db.create_global_conf(dict_mod) -def get_all_monitoring_instructions(db): - """ - runs on the database the function get_monitoring_instructions for all hosts under monitoring - :param db: the database to perform operation - :return:the monitoring instructions for all hosts - """ - res = [] - for addr_host in db.get_list_addr_hosts(): - for instr in db.get_monitoring_instructions(addr_host): - res.append(instr) - return res - - -def launch_db_function(dict_instr): - """ - Calls a function of the database with the parametters sent. Used to each function which is not module dependant : - remove host, create/remove group, add/remove to group, save settings, etc. - :param dict_instr: a dictionary containing : - { - "func" : func_name, - "args" : [arg1, ...] - } - :return: the result of the called function. Or None if the function does not returns a value. - """ - db = load_db() - return getattr(db, dict_instr['func'])(dict_instr['args']) \ No newline at end of file + def get_info_mod_monitoring(self): + """ + Get information about the output and block of the monitoring modules. These informations must be written by the + module developper on the __init__.py file (add on info_mod dictionnary). + :return: a dictionary containing these informations on the form : + {'os:{ + mod_name: {'block': val, 'unit': 'bool' or '%' or unit_name} + } + } + """ + info_mods = {} + for os in modules.monitoring_modules.__all__: + package = __import__("modules.monitoring_modules." + os, fromlist=modules.monitoring_modules.__all__) + info_mods[os] = package.info_mod + return info_mods + + + def get_conection_modules_list(self): + """ + Get a list containing the names of the different connection modules declared on the __init__.py file + of the connection_modules package. + :return: a list containing the names of the different connection modules declared on the __init__.py file + of the connection_modules package. + """ + pack_conn_os = __import__("modules.connection_modules", fromlist=modules.connection_modules.__all__) + return pack_conn_os.__all__ + + + def create_global_conf(self, db): + """ + Asks the database to create a global configuration in function of the monitoring modules descibed on the __init__.py + :param db: the database instance + """ + dict_mod = {} + for os in modules.monitoring_modules.__all__: + dict_mod[os] = self.get_info_mod_monitoring() + db.create_global_conf(dict_mod) + + + def get_all_monitoring_instructions(self, db): + """ + runs on the database the function get_monitoring_instructions for all hosts under monitoring + :param db: the database to perform operation + :return:the monitoring instructions for all hosts + """ + res = [] + for addr_host in db.get_list_addr_hosts(): + for instr in db.get_monitoring_instructions(addr_host): + res.append(instr) + return res + + + def launch_db_function(self, dict_instr): + """ + Calls a function of the database with the parametters sent. Used to each function which is not module dependant : + remove host, create/remove group, add/remove to group, save settings, etc. + :param dict_instr: a dictionary containing : + { + "func" : func_name, + "args" : [arg1, ...] + } + :return: the result of the called function. Or None if the function does not returns a value. + """ + return getattr(self.db, dict_instr['func'])(dict_instr['args']) \ No newline at end of file diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index ed7bdb5..023f073 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -13,16 +13,17 @@ class shelve_db: Storage module for the persistant objects in Python : Shelve. Every function in need to access the database have to be moved in this class. """ - def __init__(self): + def __init__(self, db_loc): self.db = None + self.db_loc = db_loc def open_db(self): """ - Open the shelve database from the file mum.db. + Open the shelve database from the file specified in conf.txt. If the file donesn't exists, it will be created and the first structure will also be initialized. """ - if not os.path.isfile("mum.db"): # init of the database at the first opening - self.db = shelve.open("mum.db", writeback=True) + if not os.path.isfile(self.db_loc): # init of the database at the first opening + self.db = shelve.open(self.db_loc, writeback=True) try: self.db["hosts"] = {} self.db["users"] = {} @@ -30,7 +31,7 @@ class shelve_db: except: print "Database initilalization error" else: - self.db = shelve.open("mum.db", writeback=True) + self.db = shelve.open(self.db_loc, writeback=True) def close_db(self): """ diff --git a/app/process_monitoring.py b/app/process_monitoring.py index e301897..32b0806 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -3,20 +3,18 @@ __author__ = 'aguilbaud' import threading from datetime import datetime from datetime import timedelta -from module_loader import run_one_monitoring_module -from module_loader import get_all_monitoring_instructions import time import sys waiting_list = [] -def init(db,wsc): - for instr in get_all_monitoring_instructions(db): +def init(ml,wsc): + for instr in ml.get_all_monitoring_instructions(ml.get_db()): #print "adding : " + str(instr) sys.stdout.flush() add_to_waiting_list(instr) - pm = ProcessMonitoring(wsc) + pm = ProcessMonitoring(ml, wsc) pm.start() @@ -36,8 +34,9 @@ class ProcessMonitoring(threading.Thread): We could use here the deque structure from Python in order to use optimized poping left, but this structure don't have implemented the insert() function, which is used for adding new data and keep the queue ordored. """ - def __init__(self, wsc): + def __init__(self, ml, wsc): threading.Thread.__init__(self) + self.ml = ml self.wsc = wsc def run(self): @@ -54,11 +53,11 @@ class ProcessMonitoring(threading.Thread): while waiting_list[len(waiting_list) - 1]['time'] <= datetime.now(): dict_mod = waiting_list.pop(len(waiting_list) - 1) modules_to_run.append(dict_mod) - dict_mod['time'] = datetime.now() + timedelta(seconds=dict_mod['freq']) + dict_mod['time'] = datetime.now() + timedelta(seconds=int(dict_mod['freq'])) add_to_waiting_list(dict_mod) ready_to_launch = True if ready_to_launch: - rm = RunMonitoring(modules_to_run, self.wsc) + rm = RunMonitoring(modules_to_run, self.ml, self.wsc) rm.start() ready_to_launch = False time.sleep(1) @@ -79,9 +78,10 @@ def add_to_waiting_list(dict_mod): class RunMonitoring(threading.Thread): - def __init__(self, list_dict_mod, wsc): + def __init__(self, list_dict_mod, ml, wsc): threading.Thread.__init__(self) self.list_dict_mod = list_dict_mod + self.ml = ml self.wsc = wsc def run(self): @@ -90,9 +90,11 @@ class RunMonitoring(threading.Thread): if dict_mod['mod_name'] == 'ping': print "Launching " + str(dict_mod['mod_name']) + " request on " + str(dict_mod['addr']) sys.stdout.flush() - run_one_monitoring_module(dict_mod['mod_name'], dict_mod['addr'], None, None, None, None) + self.ml.run_one_monitoring_module(dict_mod['mod_name'], dict_mod['addr'], None, None, None, None) else: - print "Launching " + str(dict_mod['os']) + "." + str(dict_mod['mod_name']) + " on " + str(dict_mod['addr']) + print "Launching " + str(dict_mod['os']) + "." + \ + str(dict_mod['mod_name']) + " on " + str(dict_mod['addr']) sys.stdout.flush() - run_one_monitoring_module(dict_mod['mod_name'], dict_mod['addr'], dict_mod['os'], None, None, None) + self.ml.run_one_monitoring_module(dict_mod['mod_name'], + dict_mod['addr'], dict_mod['os'], None, None, None) self.wsc.notify_state_change() \ No newline at end of file diff --git a/conf.txt b/conf.txt index 1077e84..544b1a0 100644 --- a/conf.txt +++ b/conf.txt @@ -1,2 +1,2 @@ -db_location=~/mum.db +db_location=mum.db external_modules_location=~/external/ \ No newline at end of file diff --git a/static/js/controllers/groupCtrl.js b/static/js/controllers/groupCtrl.js index f7419c2..ea4a1d3 100644 --- a/static/js/controllers/groupCtrl.js +++ b/static/js/controllers/groupCtrl.js @@ -12,14 +12,8 @@ mumApp.controller('groupCtrl', function($scope, $filter, $routeParams, DataHosts $scope.group_filter = ''; - $scope.selected = []; - - $scope.select = function(host){ - $scope.selected.append(host); - }; - - $scope.unselect = function(host){ - $scope.selected.remove(host); + $scope.selection = { + host_addrs : {} }; $scope.status = ''; diff --git a/views/groups.html b/views/groups.html index 5d29ccd..fe9eca1 100644 --- a/views/groups.html +++ b/views/groups.html @@ -33,7 +33,7 @@ <td>{{item.name}}</td> <td>{{getGroupsByAddr(item.addr)}}</td> <td> - <input type="checkbox" ng-model="item.Selected"/> + <input type="checkbox" ng-model="item.Selected" id="{{item.addr}}"/> </td> </tr> </tbody> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm