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 d8c113e2dffaca50db0241fdd7a38fd086f42146 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed May 6 11:16:38 2015 +0200 configuration of archiving --- app/modules/storage_modules/shelve_db.py | 19 +++++++++++++++++-- static/js/controllers/hostPageCtrl.js | 20 ++++++++++++++++++++ static/js/controllers/settingsCtrl.js | 14 ++++++++++++++ views/hostpage.html | 27 +++++++++++++++++++++++++++ views/settings.html | 27 +++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 2 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 50315ad..c073e08 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -156,6 +156,11 @@ class shelve_db: self.db['global_conf'][args['mod_name']]['minor_limit'] = args['minor_limit'] self.db['global_conf'][args['mod_name']]['major_limit'] = args['major_limit'] self.db['global_conf'][args['mod_name']]['check_frequency'] = args['freq'] + for period in ['min', 'hour', 'day', 'week', 'month', 'year']: + if args['nb_' + period] == '': + self.db['global_conf'][args['mod_name']]['nb_' + period] = None + else: + self.db['global_conf'][args['mod_name']]['nb_' + period] = args['nb_' + period] except Exception: print traceback.format_exc() finally: @@ -717,6 +722,8 @@ class shelve_db: res['minor_limit'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] res['major_limit'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] res['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] + for period in ['min', 'hour', 'day', 'week', 'month', 'year']: + res['nb_' + period] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['nb_' + period] except Exception: print traceback.format_exc() finally: @@ -742,6 +749,11 @@ class shelve_db: self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] = args['minor_limit'] self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] = args['major_limit'] self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] = args['freq'] + for period in ['min', 'hour', 'day', 'week', 'month', 'year']: + if args['nb_' + period] == '': + self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['nb_' + period] = None + else: + self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['nb_' + period] = args['nb_' + period] except Exception: print traceback.format_exc() finally: @@ -991,8 +1003,11 @@ class shelve_db: dict_archive[period].append(dict_check) if period == 'year' and time_diff.days >= 365: dict_archive[period].append(dict_check) - if conf_mod['nb_' + period] is not None and len(dict_archive[period]) > conf_mod['nb_' + period]: - dict_archive[period].pop(0) + if conf_mod['nb_' + period] is not None: + size_arch = len(dict_archive[period]) + while size_arch > conf_mod['nb_' + period]: + dict_archive[period].pop(0) + size_arch -= 1 return dict_archive def create_notif_structure(self, addr_host, moni_mod, status): diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index a4e0c31..78e7e85 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -301,6 +301,13 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI $scope.limit_bool = 'minor'; + $scope.arch_min = 0; + $scope.arch_hour = 0; + $scope.arch_day = 0; + $scope.arch_week = 0; + $scope.arch_month = 0; + $scope.arch_year = 0; + // when the actual conf of the module is received $scope.$on("resCall", function (event, args) { if(args.func == 'get_conf_mod'){ @@ -323,6 +330,12 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI $scope.minor_limit_unit = args.res.minor_limit; $scope.major_limit_unit = args.res.major_limit; } + $scope.arch_min = args.res.nb_min; + $scope.arch_hour = args.res.nb_hour; + $scope.arch_day = args.res.nb_day; + $scope.arch_week = args.res.nb_week; + $scope.arch_month = args.res.nb_month; + $scope.arch_year = args.res.nb_year; }, 0); } }); @@ -345,6 +358,13 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI args.minor_limit = $scope.minor_limit_unit; args.major_limit = $scope.major_limit_unit; } + args.nb_min = $scope.arch_min; + args.nb_hour = $scope.arch_hour; + args.nb_day = $scope.arch_day; + args.nb_week = $scope.arch_week; + args.nb_month = $scope.arch_month; + args.nb_year = $scope.arch_year; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"SET_CONF_MOD": args})); $modalInstance.close(); diff --git a/static/js/controllers/settingsCtrl.js b/static/js/controllers/settingsCtrl.js index 3c5fdb2..2838b2b 100644 --- a/static/js/controllers/settingsCtrl.js +++ b/static/js/controllers/settingsCtrl.js @@ -62,6 +62,13 @@ mumApp.controller('ModalGlobalConfInstanceCtrl', function ($scope, $rootScope, $ $scope.limit_bool = 'minor'; + $scope.arch_min = global_conf_args.conf_mod.nb_min; + $scope.arch_hour = global_conf_args.conf_mod.nb_hour; + $scope.arch_day = global_conf_args.conf_mod.nb_day; + $scope.arch_week = global_conf_args.conf_mod.nb_week; + $scope.arch_month = global_conf_args.conf_mod.nb_month; + $scope.arch_year = global_conf_args.conf_mod.nb_year; + if($scope.global_conf_args.conf_mod.unit == 'bool'){ if($scope.global_conf_args.conf_mod.major_limit){ $scope.limit_bool = 'major'; @@ -94,6 +101,13 @@ mumApp.controller('ModalGlobalConfInstanceCtrl', function ($scope, $rootScope, $ args.major_limit = $scope.major_limit_unit; } + args.nb_min = $scope.arch_min; + args.nb_hour = $scope.arch_hour; + args.nb_day = $scope.arch_day; + args.nb_week = $scope.arch_week; + args.nb_month = $scope.arch_month; + args.nb_year = $scope.arch_year; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'set_global_settings','args': args}})); $modalInstance.close(); diff --git a/views/hostpage.html b/views/hostpage.html index 04b5a7a..3dd625d 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -156,6 +156,33 @@ <div class="modal-body"> <form> <div class="form-group"> + <label for="arch">Archives to keep (in check numbers). Keep empty for no limit.</label> + <div class="row" id="arch"> + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="arch_min"> minute + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="arch_hour"> hour + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="23" class="form-control" + ng-model="arch_day"> day + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="7" class="form-control" + ng-model="arch_week"> week + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="31" class="form-control" + ng-model="arch_month"> month + </div> + <div class="col-xs-2"> + <input type="number" min="0" class="form-control" + ng-model="arch_year"> year + </div> + </div> <label for="freq">Frequency check: each</label> <div class="row" id="freq"> <div class="col-xs-2"> diff --git a/views/settings.html b/views/settings.html index a0c06b7..42cb1ec 100644 --- a/views/settings.html +++ b/views/settings.html @@ -19,6 +19,33 @@ <div class="modal-body"> <form> <div class="form-group"> + <label for="arch">Archives to keep (in check numbers). Keep empty for no limit.</label> + <div class="row" id="arch"> + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="arch_min"> minute + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="arch_hour"> hour + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="23" class="form-control" + ng-model="arch_day"> day + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="7" class="form-control" + ng-model="arch_week"> week + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="31" class="form-control" + ng-model="arch_month"> month + </div> + <div class="col-xs-2"> + <input type="number" min="0" class="form-control" + ng-model="arch_year"> year + </div> + </div> <label for="freq">Frequency check: each</label> <div class="row" id="freq"> <div class="col-xs-2"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.