branch develop updated (dca7d4d -> 98c99dd)
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 dca7d4d hostpage: removed useless function new 98c99dd Glances connection added + cpu with glances added + support of multi connections by priorities 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 98c99dde02634da528e9379399282a139044d837 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Apr 14 15:44:13 2015 +0200 Glances connection added + cpu with glances added + support of multi connections by priorities Summary of changes: app/module_loader.py | 164 ++++++++++++--------- app/modules/connection_modules/glances.py | 37 +++++ .../detection_modules/open_ports_detection.py | 2 +- app/modules/monitoring_modules/cpu.py | 4 +- app/modules/monitoring_modules/cpu_glances.py | 30 ++++ app/modules/monitoring_modules/disk.py | 4 +- app/modules/monitoring_modules/load.py | 4 +- app/modules/monitoring_modules/memory.py | 4 +- app/modules/monitoring_modules/ping.py | 2 + app/modules/monitoring_modules/swap.py | 4 +- app/modules/monitoring_modules/updated_packages.py | 4 +- app/modules/storage_modules/shelve_db.py | 29 +++- app/mum.py | 2 +- static/js/controllers/hostPageCtrl.js | 67 ++++----- views/hostpage.html | 8 +- 15 files changed, 237 insertions(+), 128 deletions(-) create mode 100644 app/modules/connection_modules/glances.py create mode 100644 app/modules/monitoring_modules/cpu_glances.py -- 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 98c99dde02634da528e9379399282a139044d837 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Apr 14 15:44:13 2015 +0200 Glances connection added + cpu with glances added + support of multi connections by priorities --- app/module_loader.py | 164 ++++++++++++--------- app/modules/connection_modules/glances.py | 37 +++++ .../detection_modules/open_ports_detection.py | 2 +- app/modules/monitoring_modules/cpu.py | 4 +- app/modules/monitoring_modules/cpu_glances.py | 30 ++++ app/modules/monitoring_modules/disk.py | 4 +- app/modules/monitoring_modules/load.py | 4 +- app/modules/monitoring_modules/memory.py | 4 +- app/modules/monitoring_modules/ping.py | 2 + app/modules/monitoring_modules/swap.py | 4 +- app/modules/monitoring_modules/updated_packages.py | 4 +- app/modules/storage_modules/shelve_db.py | 29 +++- app/mum.py | 2 +- static/js/controllers/hostPageCtrl.js | 67 ++++----- views/hostpage.html | 8 +- 15 files changed, 237 insertions(+), 128 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index 7347484..8edee4d 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -108,25 +108,19 @@ class ModuleLoader: for instr in monitoring_intructions: self.add_to_waiting_list(instr) - def create_connection(self, addr_host): + def create_connection(self, addr_host, conf_conn): """ Creates a connection with a host, from the configured ones. :param addr_host: the IP address of the host we want to establish a connection. - :return: An instance of the connection module once initialized. + :param conf_conn: a structure containing informations about the connection to instanciate + :return: An instance of the connection module. """ - avaliable_conn = self.db.get_conf_conn(addr_host) - mod_inst = None - if not avaliable_conn == []: - conn = avaliable_conn.pop() - mod_inst = getattr(self.loaded_mod_conn[conn['conn_mod_name']]['imported'], - self.loaded_mod_conn[conn['conn_mod_name']]['class_name'])(addr_host, - conn['args'], - self.conf['keys_location'], - modules.CommandNotFoundException) - else: - print "Error: no connection have been configured yet" - process_monitoring.remove_to_waiting_list(addr_host, None) - return mod_inst + conn_inst = getattr(self.loaded_mod_conn[conf_conn['conn_mod_name']]['imported'], + self.loaded_mod_conn[conf_conn['conn_mod_name']]['class_name'])(addr_host, + conf_conn['args'], + self.conf['keys_location'], + modules.CommandNotFoundException) + return conn_inst def test_connection(self, addr_host, conn_mod_name): """ @@ -186,20 +180,30 @@ class ModuleLoader: Instanciates and stores the informations about each monitoring modules avaliable (internal and loaded externally) on the loaded_mod_moni attribute """ + all_internal_mod = {} # for searching easily the existance of a module without specify the part for importer, mod_name, ispkg in pkgutil.iter_modules(["app/modules/monitoring_modules/"]): if mod_name not in sys.modules: try: loaded_mod = __import__("modules.monitoring_modules." + mod_name, fromlist=[mod_name]) - infos_mod = {} - infos_mod['imported'] = loaded_mod - infos_mod['compatible_os'] = getattr(loaded_mod, 'compatible_os') - for os in infos_mod['compatible_os']: - if os not in self.compatible_os_list: - self.compatible_os_list.append(os) - infos_mod['block'] = getattr(loaded_mod, 'block') - infos_mod['unit'] = getattr(loaded_mod, 'unit') - infos_mod['external'] = False - self.loaded_mod_moni[mod_name] = infos_mod + part = getattr(loaded_mod, 'part') + if part not in self.loaded_mod_moni: + self.loaded_mod_moni[part] = {} + self.loaded_mod_moni[part]['compatible_os'] = [] + self.loaded_mod_moni[part]['compatible_conn'] = [] + self.loaded_mod_moni[part]['modules'] = {} + 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. " @@ -209,95 +213,109 @@ class ModuleLoader: for importer, mod_name, ispkg in pkgutil.iter_modules([self.conf['external_modules_location']]): if mod_name not in sys.modules: loaded_mod = __import__(mod_name, fromlist=[mod_name]) - if mod_name in self.loaded_mod_moni: # if the module overrides an internal one + if mod_name in all_internal_mod: # if the module overrides an internal one + part = all_internal_mod[mod_name] for attr in dir(loaded_mod): # for each attribute on the external module if not re.search('^_{2}\S*_{2}$', attr): # we override each declarated attribute # (we don't override those named __*__) - setattr(self.loaded_mod_moni[mod_name]['imported'], + setattr(self.loaded_mod_moni[part]['modules'][mod_name]['imported'], attr, getattr(loaded_mod, attr)) - else: # otherwise, we save the external module normally + else: # otherwise, load the external module normally try: - infos_mod = {} - infos_mod['imported'] = loaded_mod - infos_mod['compatible_os'] = getattr(loaded_mod, 'compatible_os') - for os in infos_mod['compatible_os']: - if os not in self.compatible_os_list: - self.compatible_os_list.append(os) - infos_mod['block'] = getattr(loaded_mod, 'block') - infos_mod['unit'] = getattr(loaded_mod, 'unit') - infos_mod['external'] = True - self.loaded_mod_moni[mod_name] = infos_mod + part = getattr(loaded_mod, 'part') + 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]['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. " - print "Please verify that every necessary methods have been implemented." - def run_one_monitoring_module(self, mod_name, addr_host, conn, db): + def run_one_monitoring_module(self, part_name, addr_host, conn, db): """ 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 part_name: the name of the part to check :param conn: an instance of a connection module :param db: an instance of a storage module """ if db is None: db = self.get_db() - if mod_name == 'ping': - dict_notif = getattr(self.loaded_mod_moni[mod_name]['imported'], + if part_name == 'ping': + dict_notif = getattr(self.loaded_mod_moni['ping']['modules']['ping']['imported'], 'check')(db, addr_host) self.run_notification_modules(dict_notif) else: - conn = self.create_connection(addr_host) - if conn is not None: - try: - dict_notif = getattr(self.loaded_mod_moni[mod_name]['imported'], - 'check')(conn, db, modules.ModuleNotCompatibleException) - self.run_notification_modules(dict_notif) - except modules.ModuleNotCompatibleException.ModuleNotCompatibleException as mnce: - print mnce.__str__() - process_monitoring.remove_to_waiting_list(addr_host, mod_name) - except modules.CommandNotFoundException.CommandNotFoundException as cnfe: - print cnfe.__str__() - process_monitoring.remove_to_waiting_list(addr_host, mod_name) + # getting all availiable connections for this part to check + compatible_conn = self.loaded_mod_moni[part_name]['compatible_conn'] + conf_conn = self.db.get_conf_conn(addr_host) + for i in range(len(conf_conn)): + for mod in self.loaded_mod_moni[part_name]['modules']: + loaded_mod = self.loaded_mod_moni[part_name]['modules'][mod]['imported'] + if getattr(loaded_mod, 'connection') == conf_conn[i]['conn_mod_name']: + try: + conn_inst = self.create_connection(addr_host, conf_conn[i]) + dict_notif = getattr(self.loaded_mod_moni[part_name]['modules'][mod]['imported'], + 'check')(conn_inst, + db, + modules.ModuleNotCompatibleException) + self.run_notification_modules(dict_notif) + except modules.ModuleNotCompatibleException.ModuleNotCompatibleException as mnce: + print mnce.__str__() + process_monitoring.remove_to_waiting_list(addr_host, part_name) + except modules.CommandNotFoundException.CommandNotFoundException as cnfe: + print cnfe.__str__() + process_monitoring.remove_to_waiting_list(addr_host, part_name) def get_monitoring_modules_list(self): """ Get information about the output, block, compatible os and class name of the monitoring modules. These informations must be specified on each modules, and must be loaded at the launch of the application. :return: a dictionary containing these informations on the form : - { - mod_name: - { - 'class_name': val, => the name of the class to instanciate - 'imported': module => the module imported - 'compatible_os': [val1, val2, ...], => a list containing the compatibles os - 'unit': val, => the unit type of return ('%', 'bool' or other) - 'block': val, => the monitoring block of the module - 'external': False => indicates if this modules comes from external directory - } + {'min_15_load': + {'compatible_conn': ['ssh'], + 'compatible_os': ['linux'], + 'modules': + {'load': + {'imported': <module 'modules.monitoring_modules.load' from '/home/aguilbaud/mum/app/modules/monitoring_modules/load.pyc'>, + 'external': False} + } + }, + ... + }, ... } """ return self.loaded_mod_moni def get_info_mod_monitoring(self): """ - Get the necessary informations about the monitoring modules for the web application side. - :return: a JSON string containing the monitoring informations: + Get the necessary informations about the monitoring modules part for the web application side. + :return: a dictionary containing the monitoring informations: { - mod_name: + part_mod_name: { 'compatible_os': [val1, val2, ...], => a list containing the compatibles os + 'compatible_conn': [val1, ...] => a list containing the monitoring modules compatibles 'unit': val, => the unit type of return ('%', 'bool' or other) 'block': val, => the monitoring block of the module } } """ res = {} - for mod in self.loaded_mod_moni: - res[mod] = {} - res[mod]['compatible_os'] = self.loaded_mod_moni[mod]['compatible_os'] - res[mod]['unit'] = self.loaded_mod_moni[mod]['unit'] - res[mod]['block'] = self.loaded_mod_moni[mod]['block'] + for part in self.loaded_mod_moni: + res[part] = {} + res[part]['compatible_os'] = self.loaded_mod_moni[part]['compatible_os'] + res[part]['compatible_conn'] = self.loaded_mod_moni[part]['compatible_conn'] + mod_sample = self.loaded_mod_moni[part]['modules'].keys()[0] + loaded_mod_sample = self.loaded_mod_moni[part]['modules'][mod_sample]['imported'] + res[part]['unit'] = getattr(loaded_mod_sample, 'unit') + res[part]['block'] = getattr(loaded_mod_sample, 'block') return res def load_all_connection_modules(self): diff --git a/app/modules/connection_modules/glances.py b/app/modules/connection_modules/glances.py new file mode 100644 index 0000000..03def10 --- /dev/null +++ b/app/modules/connection_modules/glances.py @@ -0,0 +1,37 @@ +import xmlrpclib + + +def get_class_name(): + return "GlancesConnect" + + +class GlancesConnect: + def __init__(self, addr_host, params, key_loc, cnfe): + self.parameters = {"port": "int"} + self.name = get_class_name() + self.addr_host = addr_host + self.known_port = 61209 + self.CommandNotFoundException = cnfe + if params is not None: + self.glances_server = xmlrpclib.ServerProxy('http://' + addr_host + ':' + str(params['port'])) + + + def get_name(self): + return self.name + + def get_addr_host(self): + # Called by monitoring modules + return self.addr_host + + def get_parameters(self): + return self.parameters + + def get_known_port(self): + return self.known_port + + def exec_command(self, cmd): + out = getattr(self.glances_server, cmd)() + return out + + def disconnect(self): + self.glances_server = None \ No newline at end of file diff --git a/app/modules/detection_modules/open_ports_detection.py b/app/modules/detection_modules/open_ports_detection.py index 9a39bc5..fd04321 100644 --- a/app/modules/detection_modules/open_ports_detection.py +++ b/app/modules/detection_modules/open_ports_detection.py @@ -23,4 +23,4 @@ def run_detection(conn, db): dict_total[fields[0]].append(port_number) """ dict_total[fields[0]].append(fields[3]) - db.save_detection(conn.get_addr_host(), "open_ports_detection", json.dumps(dict_total)) \ No newline at end of file + db.save_detection(conn.get_addr_host(), "open_ports_detection", json.dumps(dict_total)) diff --git a/app/modules/monitoring_modules/cpu.py b/app/modules/monitoring_modules/cpu.py index 61c1b30..b733cad 100644 --- a/app/modules/monitoring_modules/cpu.py +++ b/app/modules/monitoring_modules/cpu.py @@ -1,9 +1,11 @@ # -*- coding: utf8 -*- __author__ = 'aguilbaud' -compatible_os = ['linux', 'unix'] +compatible_os = ['linux'] block = "hardware" +part = "cpu" unit = "%" +connection = "ssh" def check(conn, db, mnce): diff --git a/app/modules/monitoring_modules/cpu_glances.py b/app/modules/monitoring_modules/cpu_glances.py new file mode 100644 index 0000000..7b07f43 --- /dev/null +++ b/app/modules/monitoring_modules/cpu_glances.py @@ -0,0 +1,30 @@ +# -*- coding: utf8 -*- +__author__ = 'aguilbaud' + +import json + +compatible_os = ['linux', 'freebsd', 'osx', 'windows'] +block = "hardware" +part = "cpu" +unit = "%" +connection = "glances" + + +def check(conn, db, mnce): + """ + Returns the greatest between the user and system CPU charge + """ + cmd = "getCpu" + out = conn.exec_command(cmd) # '{"softirq": 0.0, "iowait": 0.1, "system": 1.1, "guest": 0.0, "idle": 96.4, + # "user": 2.3, "guest_nice": 0.0, "irq": 0.0, "steal": 0.0, "nice": 0.0}' + dict_res = json.loads(out) + try: + user_cpu_charge = dict_res["system"] + system_cpu_charge = dict_res["user"] + except KeyError: + exception_inst = getattr(mnce, "ModuleNotCompatibleException")( + "cpu_glances", conn.get_addr_host() + ) + 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 diff --git a/app/modules/monitoring_modules/disk.py b/app/modules/monitoring_modules/disk.py index 41cfd3d..ea6cd5f 100644 --- a/app/modules/monitoring_modules/disk.py +++ b/app/modules/monitoring_modules/disk.py @@ -3,9 +3,11 @@ __author__ = 'aguilbaud' import re -compatible_os = ['linux', 'unix'] +compatible_os = ['linux'] block = "hardware" +part = "disk" unit = "%" +connection = "ssh" def check(conn, db, mnce): diff --git a/app/modules/monitoring_modules/load.py b/app/modules/monitoring_modules/load.py index a85427f..ceadd21 100644 --- a/app/modules/monitoring_modules/load.py +++ b/app/modules/monitoring_modules/load.py @@ -1,9 +1,11 @@ # -*- coding: utf8 -*- __author__ = 'aguilbaud' -compatible_os = ['linux', 'unix'] +compatible_os = ['linux'] block = "hardware" +part = "min_15_load" unit = "" +connection = "ssh" def check(conn, db, mnce): diff --git a/app/modules/monitoring_modules/memory.py b/app/modules/monitoring_modules/memory.py index 7cafb09..27f8423 100644 --- a/app/modules/monitoring_modules/memory.py +++ b/app/modules/monitoring_modules/memory.py @@ -3,9 +3,11 @@ __author__ = 'aguilbaud' import re -compatible_os = ['linux', 'unix'] +compatible_os = ['linux'] block = "hardware" +part = "memory" unit = "%" +connection = "ssh" def check(conn, db, mnce): diff --git a/app/modules/monitoring_modules/ping.py b/app/modules/monitoring_modules/ping.py index 053310f..80883ae 100644 --- a/app/modules/monitoring_modules/ping.py +++ b/app/modules/monitoring_modules/ping.py @@ -5,7 +5,9 @@ import pexpect compatible_os = ["all"] block = "network" +part = "ping" unit = "bool" +connection = "" def check(db, addr_host): diff --git a/app/modules/monitoring_modules/swap.py b/app/modules/monitoring_modules/swap.py index 0c64d89..696415a 100644 --- a/app/modules/monitoring_modules/swap.py +++ b/app/modules/monitoring_modules/swap.py @@ -1,9 +1,11 @@ # -*- coding: utf8 -*- __author__ = 'aguilbaud' -compatible_os = ['linux', 'unix'] +compatible_os = ['linux'] block = "hardware" +part = "swap" unit = "%" +connection = "ssh" def check(conn, db, mnce): diff --git a/app/modules/monitoring_modules/updated_packages.py b/app/modules/monitoring_modules/updated_packages.py index 817d275..3717577 100644 --- a/app/modules/monitoring_modules/updated_packages.py +++ b/app/modules/monitoring_modules/updated_packages.py @@ -1,9 +1,11 @@ __author__ = 'aguilbaud' -compatible_os = ['linux', 'unix'] +compatible_os = ['linux'] block = "software" +part = "updated_packages" unit = "bool" +connection = "ssh" def check(conn, db, mnce): diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 122dca3..4afe0f7 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -70,6 +70,7 @@ class shelve_db: """ self.open_db() try: + for mod in loaded_mod_moni: if mod not in self.db['global_conf']: # adding a entry for every module loaded for the first time mod_conf = {} @@ -96,9 +97,13 @@ class shelve_db: mod_conf['minor_limit'] = 8 mod_conf['major_limit'] = 10 self.db['global_conf'][mod] = mod_conf - for mod in self.db['global_conf']: # removing entries of modules that are no loaded anymore + # removing entries of modules that are no loaded anymore + mods_to_del = [] + for mod in self.db['global_conf']: if mod not in loaded_mod_moni: - del self.db['global_conf'][mod] + mods_to_del.append(mod) + for mod in mods_to_del: + del self.db['global_conf'][mod] except Exception: print traceback.format_exc() finally: @@ -212,13 +217,11 @@ class shelve_db: else: for loaded_conn_mod in conn_infos: if conn_infos[loaded_conn_mod]['known_port'] == int(port['portid']): - print "noob" dict_conn[loaded_conn_mod] = {} for param in conn_infos[loaded_conn_mod]['params']: dict_conn[loaded_conn_mod][param] = None dict_conn[loaded_conn_mod]["priority"] = 0 dict_conn[loaded_conn_mod]["port"] = conn_infos[loaded_conn_mod]['known_port'] - print dict_conn return dict_conn def get_conn_param(self, args): @@ -646,6 +649,9 @@ class shelve_db: self.open_db() try: for mod in args['priorities']: + if mod not in self.db['hosts'][addr_host]['conf']['connections']: + # if the module have never been configurated for this host + self.db['hosts'][addr_host]['conf']['connections'][mod] = {} self.db['hosts'][addr_host]['conf']['connections'][mod]['priority'] = args['priorities'][mod] except Exception: print traceback.format_exc() @@ -665,8 +671,11 @@ class shelve_db: self.open_db() try: for param in args['current_config'][modname]: + if modname not in self.db['hosts'][addr_host]['conf']['connections']: + # this is the first time this connection is configured for this host + self.db['hosts'][addr_host]['conf']['connections'][modname] = {} self.db['hosts'][addr_host]['conf']['connections'][modname][param] = \ - args['current_config']['ssh'][param] + args['current_config'][modname][param] except Exception: print traceback.format_exc() finally: @@ -676,7 +685,7 @@ class shelve_db: """ Get the configured connections of a host by priority. :param addr_host: The IP address of the host. - :return: A list containing: + :return: A list, ordored by crescent priority, containing: [{'conn_mod_name': string, 'priority': int, 'args': {arg1: val, ...}}] """ res = [] @@ -688,7 +697,13 @@ class shelve_db: dict_conn['conn_mod_name'] = conn dict_conn['priority'] = self.db['hosts'][addr_host]['conf']['connections'][conn]['priority'] dict_conn['args'] = self.db['hosts'][addr_host]['conf']['connections'][conn] - res.append(dict_conn) + if res == []: + res.append(dict_conn) + else: + pos = 0 + while pos < len(res) and res[pos]['priority'] < dict_conn['priority']: + pos += 1 + res.insert(pos, dict_conn) except Exception: print traceback.format_exc() finally: diff --git a/app/mum.py b/app/mum.py index 820e602..0395b30 100755 --- a/app/mum.py +++ b/app/mum.py @@ -221,7 +221,7 @@ if __name__ == '__main__': ml.load_all_connection_modules() ml.load_all_detection_modules() ml.load_all_notification_modules() - ml.get_db().init_global_conf(ml.get_monitoring_modules_list()) + ml.get_db().init_global_conf(ml.get_info_mod_monitoring()) ml.start_monitoring() #dict_notif = ml.db.add_check('127.0.0.1', "ping", False) #ml.run_notification_modules(dict_notif) diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index d8f8737..6dcf145 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -329,6 +329,7 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI $scope.priorities[mod] = args.res[mod]['priority'] } }); + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_CONN_MOD": ""})); } if(args.func == 'set_prio_conn'){ $modalInstance.close(); @@ -336,6 +337,18 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI } }); + $scope.$on("resGetLoadedConnMod", function (event, args) { + $scope.$apply(function(){ + $scope.loaded_conn_mods = args; + for(mod in $scope.loaded_conn_mods){ + if(!$scope.current_config.hasOwnProperty(mod)){ + $scope.current_config[mod] = {}; + $scope.current_config[mod]['priority'] = 0; + } + } + }); + }); + $scope.testConn = function(connModName){ var args = {}; args['addr_host'] = $scope.conn_args["addr_host"]; @@ -362,7 +375,10 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI size: 'lg', resolve: { conf_conn_args: function(){ - return {'addr_host' : $scope.conn_args['addr_host'], 'modname': modname, 'current_config': $scope.current_config}; + return {'addr_host' : $scope.conn_args['addr_host'], + 'modname': modname, + 'current_config': $scope.current_config, + 'loaded_conn_mods': $scope.loaded_conn_mods}; } } }); @@ -376,9 +392,10 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo $scope.conf_conn_args = conf_conn_args; /* {'addr_host': val, 'modname': val, - 'current_config': val} */ + 'current_config': val + 'loaded_conn_mods': ...} */ - $scope.loaded_conn_mods = {}; /* { + $scope.loaded_conn_mods = $scope.loaded_conn_mods; /* { mod_name: { 'class_name': val, => the name of the class to instanciate @@ -388,18 +405,16 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo } */ $scope.conf_conn = {}; - $scope.port = $scope.conf_conn_args["current_config"]["ssh"]["port"]; + $scope.port = $scope.conf_conn_args["current_config"][$scope.conf_conn_args.modname]["port"]; - $scope.username = $scope.conf_conn_args["current_config"]["ssh"]["username"]; + $scope.username = $scope.conf_conn_args["current_config"][$scope.conf_conn_args.modname]["username"]; - $scope.password = $scope.conf_conn_args["current_config"]["ssh"]["password"]; + $scope.password = $scope.conf_conn_args["current_config"][$scope.conf_conn_args.modname]["password"]; - $scope.private_key = $scope.conf_conn_args["current_config"]["ssh"]["private_key"]; + $scope.private_key = $scope.conf_conn_args["current_config"][$scope.conf_conn_args.modname]["private_key"]; $scope.keys_list = []; - $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_CONN_MOD": ""})); - $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_KEYS_LIST": ""})); $scope.$on("keysList", function (event, args) { @@ -408,29 +423,6 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo }); }); - $scope.$on("resGetLoadedConnMod", function (event, args) { - $scope.$apply(function(){ - $scope.loaded_conn_mods = args; - /*for(mod in args){ - //alert(args[mod]); - for(param in args[mod]){ - $scope.conf_conn[param] = $scope.conf_conn_args["current_config"][param]; - //alert(param); - $scope.form += '<div class="row">'; - $scope.form += ' <div class="col-xs-3">'; - $scope.form += ' <label for="' + param + '">' + param + '</label>' - //if(mod['params'] == "string"){ - $scope.form += '<input type="text" id="' + param + '"/>'; - //} - $scope.form += ' </div>'; - $scope.form += '</div>'; - } - }*/ - //$templateCache.put('templateForm.html', $scope.form); - }); - - }); - $scope.$on("resCall", function (event, args) { if(args.func == 'set_conf_conn'){ $modalInstance.close(); @@ -440,11 +432,11 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo $scope.ok = function () { var args = conf_conn_args; - args['current_config']['ssh'] = {} - args['current_config']['ssh']['port'] = $scope.port; - args['current_config']['ssh']['username'] = $scope.username; - args['current_config']['ssh']['password'] = $scope.password; - args['current_config']['ssh']['private_key'] = $scope.private_key; + args['current_config'][$scope.conf_conn_args.modname] = {} + args['current_config'][$scope.conf_conn_args.modname]['port'] = $scope.port; + args['current_config'][$scope.conf_conn_args.modname]['username'] = $scope.username; + args['current_config'][$scope.conf_conn_args.modname]['password'] = $scope.password; + args['current_config'][$scope.conf_conn_args.modname]['private_key'] = $scope.private_key; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'set_conf_conn','args': args}})); @@ -470,6 +462,7 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal 'compatible_os': [val1, val2, ...], => a list containing the compatibles os 'unit': val, => the unit type of return ('%', 'bool' or other) 'block': val, => the monitoring block of the module + 'part':val => the part checked by the moni mod } } } diff --git a/views/hostpage.html b/views/hostpage.html index 45330fe..8bda3e6 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -21,8 +21,8 @@ <tbody> <tr ng-repeat="(itemname, item) in items.monitoring" - class={{item.state}} - ng-show="items.activated_monitoring[itemname]"> + class={{item.state}}> + <!--ng-show="items.activated_monitoring[itemname]"--> <td>{{itemname}}</td> <td>{{item.value}} {{get_unit(itemname)}}</td> <td>{{item.state}}</td> @@ -183,7 +183,7 @@ <div class="modal-body"> <form> <div class="form-group"> - <h3>Choose the priority of each avaliable connection</h3> + <h3>Choose the priority of each avaliable connection. The highest will be used first.</h3> <table class="table table-bordered table-hover"> <thead> <tr> @@ -287,6 +287,7 @@ <th><button type="button" class="btn" ng-click="select_all(block)">Select all</button> <button type="button" class="btn" ng-click="select_none(block)">Select none</button> </th> + <th>Compatible Connections</th> </tr> <tr ng-repeat-end ng-repeat="mod in block"> @@ -294,6 +295,7 @@ <td><input type="checkbox" ng-model="mod.activated" ng-disabled="is_not_compatible(mod.modname)"></td> + <td>{{block_args.loaded_moni_mod[mod.modname].compatible_conn}}</td> </tr> </table> </div> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm