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 a9bcc5186eb1bfa8da4a3f07ba54b9d2915ce5a3 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 18 11:51:15 2015 +0100 changer la fréquence de check d'un module est maintenant appliqué dans le process monitoring --- app/app.py | 3 +++ app/modules/storage_modules/shelve_db.py | 4 ++-- app/process_monitoring.py | 23 +++++++++++++++++++++++ static/js/controllers/hostPageCtrl.js | 4 ++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/app.py b/app/app.py index 8ffda84..1d89861 100755 --- a/app/app.py +++ b/app/app.py @@ -146,6 +146,9 @@ def receive(ws): ws.send(json_dumps({"RES_GET_LOADED_MONI_MOD": ml.get_info_mod_monitoring()})) elif code == "SET_MOD_ACTIVATION": ml.update_activated_modules(msg["SET_MOD_ACTIVATION"]) + elif code == "SET_CONF_MOD": + ml.launch_db_function({'func': 'set_conf_mod', 'args': msg["SET_CONF_MOD"]}) + process_monitoring.update_mod_on_waiting_list(msg["SET_CONF_MOD"]) elif code == "CHECK_NOW": args = msg["CHECK_NOW"] ml.run_one_monitoring_module(args['mod_name'], args['addr_host'], None, None) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 4522c9a..97e993e 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -517,7 +517,7 @@ class shelve_db: def get_conf_mod(self, args): """ - Returns a structure containing informations about the settings of a monitoring module. + Returns a structure containing informations about the settings of a monitoring module for a given host. :param args: a list containing the arguments : {'addr_host': val, 'mod_name':val] :return: a structure containing : @@ -545,7 +545,7 @@ class shelve_db: def set_conf_mod(self, args): """ - Save a new configuration for a monitoring module + Save a new configuration for a monitoring module and for a specific host. :param args: a structure containing the values : { 'addr_host': val, diff --git a/app/process_monitoring.py b/app/process_monitoring.py index c056d7f..bfe6076 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -90,6 +90,29 @@ def remove_to_waiting_list(addr_host, modname): # we remove only the necessary module from the list waiting_list.pop(i) + +def update_mod_on_waiting_list(new_conf): + """ + Updates the check frequency of a module after its configuration changed. The next check will be launched right after + this new configuration. + :param new_conf: a structure containing the values : + { + 'addr_host': val, + 'mod_name': val, + 'freq' : val, + 'minor_limit' : val, + 'major_limit' : val + } + """ + global waiting_list + for i in range(len(waiting_list)): + if waiting_list[i]['addr'] == new_conf['addr_host'] and waiting_list[i]['mod_name'] == new_conf['mod_name']: + prev_conf = waiting_list.pop(i) + prev_conf['freq'] = new_conf['freq'] + prev_conf['time'] = datetime.now() + add_to_waiting_list(prev_conf) + + class RunMonitoring(threading.Thread): def __init__(self, list_dict_mod, ml, wsc): threading.Thread.__init__(self) diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 3a10a96..0900387 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -197,7 +197,7 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI var args = {}; args.addr_host = $scope.conf_args.addr_host; args.mod_name = $scope.conf_args.mod_name; - args.freq = 86400 * parseInt($scope.freq_days) + 3600 * parseInt($scope.freq_hours) + 60 * parseInt($scope.freq_minutes); + args.freq = 86400 * $scope.freq_days + 3600 * $scope.freq_hours + 60 * $scope.freq_minutes; if($scope.items.unit == 'bool'){ args.minor_limit = ($scope.limit_bool == 'minor'); args.major_limit = ($scope.limit_bool == 'major'); @@ -210,7 +210,7 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI args.minor_limit = $scope.minor_limit_unit; args.major_limit = $scope.major_limit_unit; } - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'set_conf_mod', 'args': args}})); + $rootScope.$broadcast("sendViaWs", JSON.stringify({"SET_CONF_MOD": args})); $modalInstance.close(); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.