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 686769b5a5e4bbbeab7dee08a9a1d038c7271ba0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Apr 3 14:34:05 2015 +0200 hostpage refreshed after full detection + at the start of the service, the next check is last_check + check_freq and not datetime.now() --- app/module_loader.py | 4 +++- app/modules/storage_modules/shelve_db.py | 10 +++++++++- app/mum.py | 1 + app/process_monitoring.py | 2 -- static/js/controllers/hostPageCtrl.js | 7 +++++++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index 451aa08..b50d413 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -32,7 +32,6 @@ class ModuleLoader: self.loaded_mod_notif = {} # See load_all_notification_modules self.compatible_os_list = ['other'] # Will contain the list of os compatibles for every monitoring module loaded self.wsc = WebSocketContainer(self.db) - process_monitoring.init(self, self.wsc) def load_db(self, key_loc): """ @@ -57,6 +56,9 @@ class ModuleLoader: def add_to_waiting_list(instr): process_monitoring.add_to_waiting_list(instr) + def start_monitoring(self): + process_monitoring.init(self, self.wsc) + @staticmethod def stop_monitoring(): process_monitoring.end = True diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 5aaa385..160a48f 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -1,6 +1,7 @@ __author__ = 'aguilbaud' from datetime import datetime +from datetime import timedelta import json import shelve import traceback @@ -248,7 +249,14 @@ class shelve_db: dict_moni['addr'] = addr_host dict_moni['os'] = json.loads(self.db['hosts'][addr_host]['detected']['nmap'])['os'] dict_moni['mod_name'] = mod - dict_moni['time'] = datetime.now() + if mod in self.db['hosts'][addr_host]['monitoring']: + # the service have benn restarted, the next check will occure at last_check + check_freq + last_check = datetime.strptime(self.db['hosts'][addr_host]['monitoring'][mod]['date'], + '%Y-%m-%d %H:%M:%S.%f') + dict_moni['time'] = last_check + timedelta(seconds=self.db['hosts'][addr_host]['conf']['monitoring'][mod]['check_frequency']) + else: + # this is the first time this module will check this host, the next check will occure right now + dict_moni['time'] = datetime.now() dict_moni['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['check_frequency'] res.append(dict_moni) except Exception: diff --git a/app/mum.py b/app/mum.py index e84e63d..ef23aac 100755 --- a/app/mum.py +++ b/app/mum.py @@ -224,6 +224,7 @@ if __name__ == '__main__': ml.load_all_detection_modules() ml.load_all_notification_modules() ml.get_db().init_global_conf(ml.get_monitoring_modules_list()) + ml.start_monitoring() #dict_notif = ml.db.add_check('127.0.0.1', "ping", False) #ml.run_notification_modules(dict_notif) port = int(os.environ.get('PORT', int(conf['server_port']))) diff --git a/app/process_monitoring.py b/app/process_monitoring.py index 4ac4049..eaa4e2c 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -12,8 +12,6 @@ end = False def init(ml,wsc): for instr in ml.get_all_monitoring_instructions(): - #print "adding : " + str(instr) - sys.stdout.flush() add_to_waiting_list(instr) pm = ProcessMonitoring(ml, wsc) pm.start() diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index a35f434..2cd251a 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -89,6 +89,13 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar }); }); + // refresh after full detection + $scope.$on("success", function (event, args) { + if(args == 'Full detection'){ + $route.reload(); + } + }); + // monitoring data are updated $scope.$on("hostsUpdate", function (event, args) { $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOST_INFO": $scope.addr_host})); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.