branch develop updated (ad00240 -> e13c42c)
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 ad00240 lock ajouté dans la classe shelve + refctoring des méthodes appellant process_monitoring afin de ne plus ajour de dépendances shelve/process_monitoring (tout centraliser dans module_loader) new 686769b hostpage refreshed after full detection + at the start of the service, the next check is last_check + check_freq and not datetime.now() new e13c42c swap monitoring module added + monitoring isntructions removed from process list if execution failed The 2 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 e13c42cfe4304fdb99a09ad62f5c02d051dff02d Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Apr 3 16:16:50 2015 +0200 swap monitoring module added + monitoring isntructions removed from process list if execution failed 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() Summary of changes: app/module_loader.py | 7 ++++++- app/modules/monitoring_modules/swap.py | 26 ++++++++++++++++++++++++++ app/modules/storage_modules/shelve_db.py | 10 +++++++++- app/mum.py | 1 + app/process_monitoring.py | 2 -- static/js/controllers/hostPageCtrl.js | 7 +++++++ 6 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 app/modules/monitoring_modules/swap.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 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>.
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 e13c42cfe4304fdb99a09ad62f5c02d051dff02d Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Apr 3 16:16:50 2015 +0200 swap monitoring module added + monitoring isntructions removed from process list if execution failed --- app/module_loader.py | 3 +++ app/modules/monitoring_modules/swap.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/module_loader.py b/app/module_loader.py index b50d413..2643b3f 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -98,6 +98,7 @@ class ModuleLoader: modules.CommandNotFoundException) else: print "Error: no connection have been configured yet" + process_monitoring.remove_to_waiting_list(addr_host, None) return mod_inst def test_connection(self, addr_host, conn_mod_name): @@ -221,8 +222,10 @@ class ModuleLoader: 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) def get_monitoring_modules_list(self): """ diff --git a/app/modules/monitoring_modules/swap.py b/app/modules/monitoring_modules/swap.py new file mode 100644 index 0000000..0c64d89 --- /dev/null +++ b/app/modules/monitoring_modules/swap.py @@ -0,0 +1,26 @@ +# -*- coding: utf8 -*- +__author__ = 'aguilbaud' + +compatible_os = ['linux', 'unix'] +block = "hardware" +unit = "%" + + +def check(conn, db, mnce): + cmd = "free -m" + stdout = conn.exec_command(cmd) + swap_total = 0 + swap_used = 0 + for line in stdout.splitlines(): + fields = line.split() + if fields[0] == 'Swap:': + swap_total = fields[1] + swap_used = fields[2] + try: + res_swap = (int(swap_used) * 100) / int(swap_total) + except ZeroDivisionError: + exception_inst = getattr(mnce, "ModuleNotCompatibleException")( + "swap", conn.get_addr_host() + ) + raise exception_inst + return db.add_check(conn.get_addr_host(), 'swap', res_swap) \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm