branch develop updated (e25ed00 -> b097080)
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 e25ed00 handled exceptions on module loader + print traceback + bug fix on full detection new 038fa24 snmp monitoring modules implemented + hostpage : modal for confirmation of deletion of a host new c760a00 known ports are at least verfied once when adding a host, and if a connection is preconfigured, it will be activated new b097080 removed known ports verification because was causing random locks on db + refactored modules to move db dependency on module_loader The 3 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 b0970805803825d20468ef8dbf87a38617a45443 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Apr 21 17:58:00 2015 +0200 removed known ports verification because was causing random locks on db + refactored modules to move db dependency on module_loader commit c760a0065eec4d9537c8f76c5211a9fe2a72edb1 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Apr 21 15:23:03 2015 +0200 known ports are at least verfied once when adding a host, and if a connection is preconfigured, it will be activated commit 038fa24fcc81ccf7f5a64d9f7c5022e587429900 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Mon Apr 20 17:43:34 2015 +0200 snmp monitoring modules implemented + hostpage : modal for confirmation of deletion of a host Summary of changes: README | 11 +++- app/module_loader.py | 65 ++++++++++------------ app/modules/connection_modules/snmp.py | 9 +-- .../monitoring_modules/15_min_load_snmp_linux.py | 14 +++++ app/modules/monitoring_modules/cpu.py | 4 +- app/modules/monitoring_modules/cpu_glances.py | 4 +- app/modules/monitoring_modules/cpu_snmp_linux.py | 20 +++++++ app/modules/monitoring_modules/disk.py | 4 +- app/modules/monitoring_modules/disk_snmp_linux.py | 16 ++++++ app/modules/monitoring_modules/load.py | 4 +- app/modules/monitoring_modules/memory.py | 4 +- .../monitoring_modules/memory_snmp_linux.py | 16 ++++++ app/modules/monitoring_modules/ping.py | 4 +- app/modules/monitoring_modules/smtp.py | 18 ++++++ app/modules/monitoring_modules/swap.py | 4 +- app/modules/monitoring_modules/swap_snmp_linux.py | 16 ++++++ app/modules/monitoring_modules/updated_packages.py | 4 +- app/modules/nmap_detection.py | 5 +- app/modules/storage_modules/shelve_db.py | 28 +++++++--- app/mum.py | 2 +- app/process_monitoring.py | 11 +--- static/js/controllers/dashboardCtrl.js | 2 +- static/js/controllers/hostPageCtrl.js | 58 ++++++++++++++----- views/dashboard.html | 2 +- views/hostpage.html | 46 ++++++++++++--- 25 files changed, 273 insertions(+), 98 deletions(-) create mode 100644 app/modules/monitoring_modules/15_min_load_snmp_linux.py create mode 100644 app/modules/monitoring_modules/cpu_snmp_linux.py create mode 100644 app/modules/monitoring_modules/disk_snmp_linux.py create mode 100644 app/modules/monitoring_modules/memory_snmp_linux.py create mode 100644 app/modules/monitoring_modules/smtp.py create mode 100644 app/modules/monitoring_modules/swap_snmp_linux.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 038fa24fcc81ccf7f5a64d9f7c5022e587429900 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Mon Apr 20 17:43:34 2015 +0200 snmp monitoring modules implemented + hostpage : modal for confirmation of deletion of a host --- README | 11 +++- app/module_loader.py | 2 +- app/modules/connection_modules/snmp.py | 9 ++-- .../monitoring_modules/15_min_load_snmp_linux.py | 14 ++++++ app/modules/monitoring_modules/cpu_snmp_linux.py | 20 ++++++++ app/modules/monitoring_modules/disk_snmp_linux.py | 16 ++++++ .../monitoring_modules/memory_snmp_linux.py | 16 ++++++ app/modules/monitoring_modules/smtp.py | 18 +++++++ app/modules/monitoring_modules/swap_snmp_linux.py | 16 ++++++ app/modules/storage_modules/shelve_db.py | 8 +-- static/js/controllers/hostPageCtrl.js | 58 +++++++++++++++++----- views/hostpage.html | 46 +++++++++++++---- 12 files changed, 203 insertions(+), 31 deletions(-) diff --git a/README b/README index 757eed3..7821db3 100644 --- a/README +++ b/README @@ -40,6 +40,13 @@ all avaliable arguments, type : The service will be avaliable by default on 0.0.0.0:1337 +We recommand to parameter the default settings for each modules before adding any hosts. +The default parameters that will be applied are : +- minor limit at 90% and major limit at 98% for each "%" values +- major limit if down for boolean values +- minor limit at 8 and major limit at 10 for any other type of values +- a check frequency of 1 minute for every module. + --------- Updates --------- @@ -48,7 +55,9 @@ git pull bower install -edit local configuration file +./install.sh + +edit local configuration file by following the latest model remove database diff --git a/app/module_loader.py b/app/module_loader.py index eb95f05..8226bb2 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -317,7 +317,7 @@ class ModuleLoader: dict_deactivation_request['activated'] = {part_name: False} self.db.config_mod_activation(dict_deactivation_request) if not conn_found: - print "No necessary connection have been configured for " + part_name + " on " + addr_host +\ + print "No necessary connection have been properly configured for " + part_name + " on " + addr_host +\ ". Therefore it has been deactivated." process_monitoring.remove_to_waiting_list(addr_host, part_name) dict_deactivation_request = {} diff --git a/app/modules/connection_modules/snmp.py b/app/modules/connection_modules/snmp.py index 2541f62..79acf7b 100644 --- a/app/modules/connection_modules/snmp.py +++ b/app/modules/connection_modules/snmp.py @@ -2,6 +2,7 @@ __author__ = 'aguilbaud' from pysnmp.entity.rfc3413.oneliner import cmdgen + def get_class_name(): return "SNMP" @@ -9,6 +10,7 @@ def get_class_name(): class SNMP: def __init__(self, addr_host, params, key_loc, cnfe): self.parameters = {"port": "int"} + self.params_stored = params self.name = get_class_name() self.addr_host = addr_host self.known_port = 161 @@ -32,7 +34,7 @@ class SNMP: res = "" errorIndication, errorStatus, errorIndex, varBinds = self.cmdGen.getCmd( cmdgen.CommunityData('public'), - cmdgen.UdpTransportTarget((self.addr_host, self.parameters['port'])), + cmdgen.UdpTransportTarget((self.addr_host, int(self.params_stored['port']))), cmd ) @@ -44,8 +46,7 @@ class SNMP: print('%s at %s' % ( errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex)-1] or '?' - ) - ) + )) else: for name, val in varBinds: if val == "": @@ -54,7 +55,7 @@ class SNMP: ) raise exception_inst else: - res = val + res = val.prettyPrint() return res def disconnect(self): diff --git a/app/modules/monitoring_modules/15_min_load_snmp_linux.py b/app/modules/monitoring_modules/15_min_load_snmp_linux.py new file mode 100644 index 0000000..4275b85 --- /dev/null +++ b/app/modules/monitoring_modules/15_min_load_snmp_linux.py @@ -0,0 +1,14 @@ +# -*- coding: utf8 -*- +__author__ = 'aguilbaud' + +compatible_os = ['linux'] +block = "hardware" +part = "min_15_load" +unit = "" +connection = "snmp" + + +def check(conn, db, mnce): + oid = ".1.3.6.1.4.1.2021.10.1.3.3" + load = float(conn.exec_command(oid)) + return db.add_check(conn.get_addr_host(), part, load) \ No newline at end of file diff --git a/app/modules/monitoring_modules/cpu_snmp_linux.py b/app/modules/monitoring_modules/cpu_snmp_linux.py new file mode 100644 index 0000000..e17f638 --- /dev/null +++ b/app/modules/monitoring_modules/cpu_snmp_linux.py @@ -0,0 +1,20 @@ +# -*- coding: utf8 -*- +__author__ = 'aguilbaud' + +compatible_os = ['linux'] +block = "hardware" +part = "cpu" +unit = "%" +connection = "snmp" + + +def check(conn, db, mnce): + """ + Check the greatest between the user and system CPU charge + """ + oid = ".1.3.6.1.4.1.2021.11.9.0" + user_cpu_charge = int(conn.exec_command(oid)) + oid = ".1.3.6.1.4.1.2021.11.10.0" + system_cpu_charge = int(conn.exec_command(oid)) + res_cpu = max(user_cpu_charge, system_cpu_charge) + return db.add_check(conn.get_addr_host(), part, res_cpu) \ No newline at end of file diff --git a/app/modules/monitoring_modules/disk_snmp_linux.py b/app/modules/monitoring_modules/disk_snmp_linux.py new file mode 100644 index 0000000..d5a584a --- /dev/null +++ b/app/modules/monitoring_modules/disk_snmp_linux.py @@ -0,0 +1,16 @@ +__author__ = 'aguilbaud' + +compatible_os = ['linux'] +block = "hardware" +part = "disk" +unit = "%" +connection = "snmp" + + +def check(conn, db, mnce): + oid = ".1.3.6.1.4.1.2021.9.1.7.1" + total_space_on_disk = float(conn.exec_command(oid)) + oid = ".1.3.6.1.4.1.2021.9.1.8.1" + disk_used = float(conn.exec_command(oid)) + percent_disk_used = round((disk_used * 100) / total_space_on_disk, 2) + return db.add_check(conn.get_addr_host(), part, percent_disk_used) \ No newline at end of file diff --git a/app/modules/monitoring_modules/memory_snmp_linux.py b/app/modules/monitoring_modules/memory_snmp_linux.py new file mode 100644 index 0000000..9459346 --- /dev/null +++ b/app/modules/monitoring_modules/memory_snmp_linux.py @@ -0,0 +1,16 @@ +__author__ = 'aguilbaud' + +compatible_os = ['linux'] +block = "hardware" +part = "memory" +unit = "%" +connection = "snmp" + + +def check(conn, db, mnce): + oid = ".1.3.6.1.4.1.2021.4.5.0" + total_mem = float(conn.exec_command(oid)) + oid = ".1.3.6.1.4.1.2021.4.6.0" + mem_used = float(conn.exec_command(oid)) + percent_mem_used = round((mem_used * 100) / total_mem, 2) + return db.add_check(conn.get_addr_host(), part, percent_mem_used) \ No newline at end of file diff --git a/app/modules/monitoring_modules/smtp.py b/app/modules/monitoring_modules/smtp.py new file mode 100644 index 0000000..80cb00f --- /dev/null +++ b/app/modules/monitoring_modules/smtp.py @@ -0,0 +1,18 @@ +__author__ = 'aguilbaud' + +import smtplib + +compatible_os = ["all"] +block = "network" +part = "smtp" +unit = "bool" +connection = "" + +def check(db, addr_host, smtp_port): + res_smtp_check = True + try: + s = smtplib.SMTP(addr_host, smtp_port) + except Exception: + res_smtp_check = False + finally: + return db.add_check(addr_host, part, res_smtp_check) \ No newline at end of file diff --git a/app/modules/monitoring_modules/swap_snmp_linux.py b/app/modules/monitoring_modules/swap_snmp_linux.py new file mode 100644 index 0000000..cbb60a8 --- /dev/null +++ b/app/modules/monitoring_modules/swap_snmp_linux.py @@ -0,0 +1,16 @@ +__author__ = 'aguilbaud' + +compatible_os = ['linux'] +block = "hardware" +part = "swap" +unit = "%" +connection = "snmp" + + +def check(conn, db, mnce): + oid = ".1.3.6.1.4.1.2021.4.3.0" + total_swap = float(conn.exec_command(oid)) + oid = ".1.3.6.1.4.1.2021.4.4.0" + swap_used = total_swap - float(conn.exec_command(oid)) + percent_swap_used = round( (swap_used * 100) / total_swap, 2) + return db.add_check(conn.get_addr_host(), part, percent_swap_used) \ No newline at end of file diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index acecdd2..23c3a32 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -89,8 +89,8 @@ class shelve_db: unit = loaded_mod_moni[mod]['unit'] mod_conf['unit'] = unit if unit == '%': - mod_conf['minor_limit'] = 95 - mod_conf['major_limit'] = 100 + mod_conf['minor_limit'] = 90 + mod_conf['major_limit'] = 98 elif unit == 'bool': mod_conf['minor_limit'] = False mod_conf['major_limit'] = True @@ -854,8 +854,10 @@ class shelve_db: ... } """ - title = "[Mum] " + status + " for " + addr_host + title = "[Mum] " + status + " for " + addr_host + " " + moni_mod msg = "Mum reported a " + status + " value from the " + moni_mod + " module. " + msg += "The following users will be notified: " + msg += self.db['hosts'][addr_host]['subscribers'] dict_notif = {} notif_type = "" if status == 'warning': diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 8a86c2a..b7f3e4c 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -72,6 +72,17 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar return res } + $scope.popover_message = function(){ + msg = ""; + if($scope.items.status == "idling"){ + msg = "Click to activate again the monitoring for this host."; + } + else{ + msg = "Click to suspend the monitoring for this host."; + } + return msg + } + $scope.$on("resCall", function (event, args) { if(args.func == 'update_os_name'){ $route.reload(); @@ -133,13 +144,6 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOST_INFO": $scope.addr_host})); }); - $scope.$on("remHost", function (event, args) { - $timeout(function() { - $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); - $location.path('/'); - }, 0); - }); - // save custom informations $scope.save_custom_infos = function(){ var args = {}; @@ -148,12 +152,6 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_custom_informations', 'args': args}})); }; - $scope.remove_host = function(){ - var args = {}; - args['addr_host'] = $scope.addr_host; - $rootScope.$broadcast("sendViaWs", JSON.stringify({"REM_HOST": args})); - }; - // creation of modals $scope.open_modal_conf = function (mod_name) { var modalInstance = $modal.open({ @@ -206,6 +204,18 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar } }); }; + + $scope.open_modal_confirm_delete = function () { + var modalInstance = $modal.open({ + templateUrl: 'modal_confirm_delete_label.html', + controller: 'ModalConfirmDeleteInstanceCtrl', + resolve: { + confirm_delete_args: function(){ + return {'addr_host' : $scope.addr_host}; + } + } + }); + }; }); // modals controllers @@ -560,4 +570,26 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal $scope.cancel = function () { $modalInstance.close(); }; +}); + +mumApp.controller('ModalConfirmDeleteInstanceCtrl', function ($scope, $rootScope, $modalInstance, $location, $timeout, confirm_delete_args) { + $scope.confirm_delete_args = confirm_delete_args; + + $scope.ok = function () { + var args = {}; + args['addr_host'] = $scope.confirm_delete_args.addr_host; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"REM_HOST": args})); + }; + + $scope.$on("remHost", function (event, args) { + $timeout(function() { + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); + $location.path('/'); + $modalInstance.close(); + }, 0); + }); + + $scope.cancel = function () { + $modalInstance.close(); + }; }); \ No newline at end of file diff --git a/views/hostpage.html b/views/hostpage.html index ce5b837..cc79503 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -1,20 +1,32 @@ <div class="col-md-offset-2 main"> - <h1 class="page-header">Current state of {{addr_host}} <small>{{items.hostname}}</small> + <h1 class="page-header">Current state of {{addr_host}} <small>{{items.hostname}} <button type="button" class="btn btn-{{get_idle_state()}}" aria-label="Button activation" + style="" + popover-placement="bottom" + popover="{{popover_message()}}" + popover-trigger="mouseenter" ng-click="set_idle_state()"> <span class="glyphicon glyphicon-off" aria-hidden="true"></span> - </button></h1> + </button></small></h1> <button type="button" class="btn btn-primary btn-xs" ng-click="open_modal_block()" - popover="Activate or deactivate monitoring modules by block." + popover="Activate or deactivate monitoring modules by section." popover-trigger="mouseenter" ng-disabled="items.status == 'idling'">Activate/Deactivate</button> - <button type="button" class="btn btn-primary btn-xs" ng-click="open_modal_conn()">Connection settings</button> - <button type="button" class="btn btn-info btn-xs" ng-click="launch_detection()">Launch a full detection</button> - <button type="button" class="btn btn-danger btn-xs" ng-click="remove_host()">Remove this host</button> + <button type="button" + class="btn btn-primary btn-xs" + ng-click="open_modal_conn()">Connection settings</button> + <button type="button" + class="btn btn-info btn-xs" + ng-click="launch_detection()" + popover="Needs SSH to be configured" + popover-trigger="mouseenter">Launch a full detection</button> + <button type="button" + class="btn btn-danger btn-xs" + ng-click="open_modal_confirm_delete()">Remove this host</button> <table class="table table-condensed table-hover" ng-show="items.status != 'idling'"> <thead> @@ -29,8 +41,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> @@ -198,7 +210,8 @@ <div class="modal-body"> <form> <div class="form-group"> - <h3>Choose the priority of each avaliable connection. The highest will be used first.</h3> + <h3>Choose the priority of each avaliable connection. The highest will be used first. + Set at 0 to not use this connection.</h3> <table class="table table-bordered table-hover"> <thead> <tr> @@ -320,4 +333,19 @@ ng-click="ok()">Save changes</button> </div> </script> + + <script type="text/ng-template" id="modal_confirm_delete_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Are you sure you want to delete {{confirm_delete_args.addr_host}} ?</h3> + </div> + <div class="modal-body"> + <p>This action will be permanent.</p> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" + ng-click="cancel()">Close</button> + <button type="button" class="btn btn-danger" + ng-click="ok()">Delete this host</button> + </div> + </script> </div> \ No newline at end of file -- 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 c760a0065eec4d9537c8f76c5211a9fe2a72edb1 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Apr 21 15:23:03 2015 +0200 known ports are at least verfied once when adding a host, and if a connection is preconfigured, it will be activated --- app/module_loader.py | 48 ++++++++++++-------------- app/modules/nmap_detection.py | 9 +++-- app/modules/storage_modules/shelve_db.py | 59 +++++++++++++++++++++++++++++--- 3 files changed, 83 insertions(+), 33 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index 8226bb2..fb89d0b 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -53,6 +53,12 @@ class ModuleLoader: def get_websocket_container(self): return self.wsc + def get_all_known_ports(self): + res = [] + for conn_mod in self.loaded_mod_conn: + res.append(self.loaded_mod_conn[conn_mod]['known_port']) + return res + def create_task(self, task_id): self.db.store_task(task_id) self.wsc.notify_task_change() @@ -87,6 +93,7 @@ class ModuleLoader: ws, self.get_conection_modules_list(), self.get_monitoring_modules_list(), + self.get_all_known_ports(), modules.HostNotFoundException) try: if re.search('^\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?$', param): @@ -112,7 +119,11 @@ class ModuleLoader: fake_nmap_res['addr'] = addr_host fake_nmap_res['hostname'] = '' fake_nmap_res['openports'] = [] - self.db.add_host(addr_host, json.dumps(fake_nmap_res), self.get_conection_modules_list(), self.get_monitoring_modules_list()) + self.db.add_host(addr_host, + json.dumps(fake_nmap_res), + self.get_conection_modules_list(), + self.get_monitoring_modules_list(), + self.get_all_known_ports()) monitoring_intructions = self.db.get_monitoring_instructions(addr_host) for instr in monitoring_intructions: self.add_to_waiting_list(instr) @@ -277,15 +288,15 @@ class ModuleLoader: # 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) - conn_found = False - for i in range(len(conf_conn)): + check_done = False + i = 0 + while i < len(conf_conn) and not check_done: # for each connection that have been configurated for this host (by priority) for mod in self.loaded_mod_moni[part_name]['modules']: # for each monitoring module, being from this part, activated for this host loaded_mod = self.loaded_mod_moni[part_name]['modules'][mod]['imported'] if getattr(loaded_mod, 'connection') == conf_conn[i]['conn_mod_name']: # if this monitoring module is compatible for the current connection - conn_found = True try: conn_inst = self.create_connection(addr_host, conf_conn[i]) dict_notif = getattr(self.loaded_mod_moni[part_name]['modules'][mod]['imported'], @@ -293,30 +304,15 @@ class ModuleLoader: 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) - dict_deactivation_request = {} - dict_deactivation_request['addr_host'] = addr_host - dict_deactivation_request['activated'] = {part_name: False} - self.db.config_mod_activation(dict_deactivation_request) - except modules.CommandNotFoundException.CommandNotFoundException as cnfe: - print cnfe.__str__() - process_monitoring.remove_to_waiting_list(addr_host, part_name) - dict_deactivation_request = {} - dict_deactivation_request['addr_host'] = addr_host - dict_deactivation_request['activated'] = {part_name: False} - self.db.config_mod_activation(dict_deactivation_request) + check_done = True except Exception: - print "Monitoring module " + part_name + " have been disabled on " + addr_host + \ - " because of an unexpected error. Traceback:" + print "The connection could not have been established with " + conf_conn[i]['conn_mod_name']\ + + " on " + addr_host + ". Traceback:" print traceback.format_exc() - process_monitoring.remove_to_waiting_list(addr_host, part_name) - dict_deactivation_request = {} - dict_deactivation_request['addr_host'] = addr_host - dict_deactivation_request['activated'] = {part_name: False} - self.db.config_mod_activation(dict_deactivation_request) - if not conn_found: + # set failed conn priority to 0 ? + print "Now trying on next avaliable connection..." + i += 1 + if not check_done: print "No necessary connection have been properly configured for " + part_name + " on " + addr_host +\ ". Therefore it has been deactivated." process_monitoring.remove_to_waiting_list(addr_host, part_name) diff --git a/app/modules/nmap_detection.py b/app/modules/nmap_detection.py index 279dee0..0c08fb4 100644 --- a/app/modules/nmap_detection.py +++ b/app/modules/nmap_detection.py @@ -8,7 +8,7 @@ from string import letters class nmap_detection: - def __init__(self, opt, db, ws, list_mod_conn, dict_mod_monitoring, hnfe): + def __init__(self, opt, db, ws, list_mod_conn, dict_mod_monitoring, known_ports, hnfe): self.opt = opt self.db = db self.ws = ws @@ -16,6 +16,7 @@ class nmap_detection: self.scanned_ip = [] self.list_mod_conn = list_mod_conn self.dict_mod_monitoring = dict_mod_monitoring + self.known_ports = known_ports self.HostNotFoundException = hnfe # function for splitting the different ranges of the IP adress @@ -166,5 +167,9 @@ class nmap_detection: list_dict_port.append(dict_port) dict_host['openports'] = list_dict_port # the host have its IP for ID on the db - self.db.add_host(dict_host['addr'], json.dumps(dict_host), self.list_mod_conn, self.dict_mod_monitoring) + self.db.add_host(dict_host['addr'], + json.dumps(dict_host), + self.list_mod_conn, + self.dict_mod_monitoring, + self.known_ports) self.scanned_ip.append(dict_host['addr']) \ No newline at end of file diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 23c3a32..2e7f768 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -6,6 +6,7 @@ import json import shelve import traceback import threading +import socket import os.path @@ -76,7 +77,9 @@ class shelve_db: if mod not in self.db['global_conf']: # adding a entry for every module loaded for the first time mod_conf = {} mod_conf['block'] = loaded_mod_moni[mod]['block'] - mod_conf['activated'] = mod == 'ping' # we want the ping module to be activated by default + # all modules are added if the os is compatible, we'll try at least + # once the check, if it exists a connection that can lauch the module + mod_conf['activated'] = True mod_conf['check_frequency'] = 60 """ mod_conf['nb_minute'] = 30 @@ -147,9 +150,9 @@ class shelve_db: finally: self.close_db() - def add_host(self, addr_host, nmap_res, conn_infos, dict_mod_info): + def add_host(self, addr_host, nmap_res, conn_infos, dict_mod_info, known_ports): """ - Called by the nmap_detection module. + Called by the nmap_detection module or directly by the module loader if no detection was asked. Add and save a new host after its first nmap detection It also preconfigure with the default configuration, add the host to the group "all" and creates empty structures for the monitoring and archive data. @@ -159,6 +162,8 @@ class shelve_db: (see get_conection_modules_list() on module_loader) :param dict_mod_info: a dictionnary containing informations about the different monitoring modules (see get_info_mod_monitoring() on module_loader) + :param a list of integers representing the known ports for the connection modules, that may not have been + detected by nmap """ self.open_db() addr_host = str(addr_host) # Shelve doesn't support Unicode @@ -170,6 +175,10 @@ class shelve_db: # Preconfiguration self.db["hosts"][addr_host]["conf"] = {} nmap_res_data = json.loads(nmap_res) + nmap_res_data['openports'] = self.check_if_known_port_is_open(addr_host, + known_ports, + nmap_res_data['openports']) + self.db["hosts"][addr_host]['detected']['nmap'] = json.dumps(nmap_res_data) self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, conn_infos) os_host = nmap_res_data['os'] self.db["hosts"][addr_host]["conf"]["monitoring"] = {} @@ -180,7 +189,7 @@ class shelve_db: self.db['hosts'][addr_host]['conf']['idling']['modules'] = [] self.db['hosts'][addr_host]['conf']['idling']['status'] = "" self.db["hosts"][addr_host]["conf"]["groups"] = ["all"] # Every host is in group "all" - self.db["hosts"][addr_host]["conf"]["subscribers"] = {} # Add current user automatically ? + self.db["hosts"][addr_host]["conf"]["subscribers"] = {} self.db["hosts"][addr_host]["conf"]["custom_info"] = "" self.db["hosts"][addr_host]["conf"]["interventions"] = [] # Create structure for monitoring data @@ -195,6 +204,40 @@ class shelve_db: self.close_db() @staticmethod + def check_if_known_port_is_open(addr_host, known_ports, openports): + """ + For each known_port that may not be detected by nmap, we will try to verify if this port is open or not by + opening a socket. + :param addr_host: the IP address of the host + :param known_ports: a list containing integers representing the known_ports to verify. + :param openports: a dictionary containing the nmap result of the detected open ports + :return: openports attribute with new fields for each open port newly verified. + """ + new_port_dict_list = [] + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + for port_id in known_ports: + print port_id + port_id_was_detected = False + for port_dict in openports: + if port_dict['portid'] == port_id: + print 1 + port_id_was_detected = True + if not port_id_was_detected: + try: + if sock.connect_ex((addr_host, port_id)) == 0: + print 2 + new_port_dict_list.append({"portname": "", "portid": port_id}) + except Exception: + pass + print new_port_dict_list + for new_port_dict in new_port_dict_list: + openports.append(new_port_dict) + print openports + finally: + return openports + + @staticmethod def init_conn(dict_nmap_res, conn_infos): """ Returns an initialization for the connection configuration on a host. @@ -224,7 +267,13 @@ class shelve_db: 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 + if len(conn_infos[loaded_conn_mod]['params'].keys()) == 1 and \ + 'port' in conn_infos[loaded_conn_mod]['params']: + # if there is only the port to configure, the conn module can be activated because is + # already configured + dict_conn[loaded_conn_mod]["priority"] = 1 + else: + dict_conn[loaded_conn_mod]["priority"] = 0 dict_conn[loaded_conn_mod]["port"] = conn_infos[loaded_conn_mod]['known_port'] return dict_conn -- 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 b0970805803825d20468ef8dbf87a38617a45443 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Apr 21 17:58:00 2015 +0200 removed known ports verification because was causing random locks on db + refactored modules to move db dependency on module_loader --- app/module_loader.py | 23 ++++++------ .../monitoring_modules/15_min_load_snmp_linux.py | 4 +-- app/modules/monitoring_modules/cpu.py | 4 +-- app/modules/monitoring_modules/cpu_glances.py | 4 +-- app/modules/monitoring_modules/cpu_snmp_linux.py | 4 +-- app/modules/monitoring_modules/disk.py | 4 +-- app/modules/monitoring_modules/disk_snmp_linux.py | 4 +-- app/modules/monitoring_modules/load.py | 4 +-- app/modules/monitoring_modules/memory.py | 4 +-- .../monitoring_modules/memory_snmp_linux.py | 4 +-- app/modules/monitoring_modules/ping.py | 4 +-- app/modules/monitoring_modules/smtp.py | 4 +-- app/modules/monitoring_modules/swap.py | 4 +-- app/modules/monitoring_modules/swap_snmp_linux.py | 4 +-- app/modules/monitoring_modules/updated_packages.py | 4 +-- app/modules/nmap_detection.py | 6 ++-- app/modules/storage_modules/shelve_db.py | 41 ++-------------------- app/mum.py | 2 +- app/process_monitoring.py | 11 ++---- static/js/controllers/dashboardCtrl.js | 2 +- views/dashboard.html | 2 +- 21 files changed, 48 insertions(+), 95 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index fb89d0b..26a539e 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -52,12 +52,13 @@ class ModuleLoader: def get_websocket_container(self): return self.wsc - + """ def get_all_known_ports(self): res = [] for conn_mod in self.loaded_mod_conn: res.append(self.loaded_mod_conn[conn_mod]['known_port']) return res + """ def create_task(self, task_id): self.db.store_task(task_id) @@ -93,7 +94,6 @@ class ModuleLoader: ws, self.get_conection_modules_list(), self.get_monitoring_modules_list(), - self.get_all_known_ports(), modules.HostNotFoundException) try: if re.search('^\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?$', param): @@ -122,8 +122,7 @@ class ModuleLoader: self.db.add_host(addr_host, json.dumps(fake_nmap_res), self.get_conection_modules_list(), - self.get_monitoring_modules_list(), - self.get_all_known_ports()) + self.get_monitoring_modules_list()) monitoring_intructions = self.db.get_monitoring_instructions(addr_host) for instr in monitoring_intructions: self.add_to_waiting_list(instr) @@ -270,19 +269,17 @@ class ModuleLoader: print "Error : external monitoring module " + mod_name + " could not have been loaded. Traceback:" print traceback.format_exc() - def run_one_monitoring_module(self, part_name, addr_host, conn, db): + def run_one_monitoring_module(self, part_name, addr_host): """ Instanciates and runs one monitoring_module of the package corresponding to the operating system entered in parameters. :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 + :param addr_host: the IP address of the host """ - if db is None: - db = self.get_db() if part_name == 'ping': - dict_notif = getattr(self.loaded_mod_moni['ping']['modules']['ping']['imported'], - 'check')(db, addr_host) + res_check = getattr(self.loaded_mod_moni['ping']['modules']['ping']['imported'], + 'check')(addr_host) + dict_notif = self.db.add_check(addr_host, part_name, res_check) self.run_notification_modules(dict_notif) else: # getting all availiable connections for this part to check @@ -299,10 +296,10 @@ class ModuleLoader: # if this monitoring module is compatible for the current connection try: conn_inst = self.create_connection(addr_host, conf_conn[i]) - dict_notif = getattr(self.loaded_mod_moni[part_name]['modules'][mod]['imported'], + res_check = getattr(self.loaded_mod_moni[part_name]['modules'][mod]['imported'], 'check')(conn_inst, - db, modules.ModuleNotCompatibleException) + dict_notif = self.db.add_check(conn_inst.get_addr_host(), part_name, res_check) self.run_notification_modules(dict_notif) check_done = True except Exception: diff --git a/app/modules/monitoring_modules/15_min_load_snmp_linux.py b/app/modules/monitoring_modules/15_min_load_snmp_linux.py index 4275b85..00ab092 100644 --- a/app/modules/monitoring_modules/15_min_load_snmp_linux.py +++ b/app/modules/monitoring_modules/15_min_load_snmp_linux.py @@ -8,7 +8,7 @@ unit = "" connection = "snmp" -def check(conn, db, mnce): +def check(conn, mnce): oid = ".1.3.6.1.4.1.2021.10.1.3.3" load = float(conn.exec_command(oid)) - return db.add_check(conn.get_addr_host(), part, load) \ No newline at end of file + return load \ No newline at end of file diff --git a/app/modules/monitoring_modules/cpu.py b/app/modules/monitoring_modules/cpu.py index b733cad..7127125 100644 --- a/app/modules/monitoring_modules/cpu.py +++ b/app/modules/monitoring_modules/cpu.py @@ -8,7 +8,7 @@ unit = "%" connection = "ssh" -def check(conn, db, mnce): +def check(conn, mnce): """ Returns the greatest between the user and system CPU charge """ @@ -30,4 +30,4 @@ def check(conn, db, mnce): field_sys = field_sys.replace(',', '.') system_cpu_charge = float(field_sys) res_cpu = max(user_cpu_charge, system_cpu_charge) - return db.add_check(conn.get_addr_host(), 'cpu', res_cpu) \ No newline at end of file + return res_cpu \ No newline at end of file diff --git a/app/modules/monitoring_modules/cpu_glances.py b/app/modules/monitoring_modules/cpu_glances.py index a16ac18..b7cc8da 100644 --- a/app/modules/monitoring_modules/cpu_glances.py +++ b/app/modules/monitoring_modules/cpu_glances.py @@ -10,7 +10,7 @@ unit = "%" connection = "glances" -def check(conn, db, mnce): +def check(conn, mnce): """ Returns the greatest between the user and system CPU charge """ @@ -27,4 +27,4 @@ def check(conn, db, mnce): ) raise exception_inst res_cpu = max(user_cpu_charge, system_cpu_charge) - return db.add_check(conn.get_addr_host(), 'cpu', res_cpu) \ No newline at end of file + return res_cpu \ No newline at end of file diff --git a/app/modules/monitoring_modules/cpu_snmp_linux.py b/app/modules/monitoring_modules/cpu_snmp_linux.py index e17f638..fad9f05 100644 --- a/app/modules/monitoring_modules/cpu_snmp_linux.py +++ b/app/modules/monitoring_modules/cpu_snmp_linux.py @@ -8,7 +8,7 @@ unit = "%" connection = "snmp" -def check(conn, db, mnce): +def check(conn, mnce): """ Check the greatest between the user and system CPU charge """ @@ -17,4 +17,4 @@ def check(conn, db, mnce): oid = ".1.3.6.1.4.1.2021.11.10.0" system_cpu_charge = int(conn.exec_command(oid)) res_cpu = max(user_cpu_charge, system_cpu_charge) - return db.add_check(conn.get_addr_host(), part, res_cpu) \ No newline at end of file + return res_cpu \ No newline at end of file diff --git a/app/modules/monitoring_modules/disk.py b/app/modules/monitoring_modules/disk.py index ea6cd5f..73b0129 100644 --- a/app/modules/monitoring_modules/disk.py +++ b/app/modules/monitoring_modules/disk.py @@ -10,7 +10,7 @@ unit = "%" connection = "ssh" -def check(conn, db, mnce): +def check(conn, mnce): cmd = "df -h" stdout = conn.exec_command(cmd) disk_used = None @@ -29,4 +29,4 @@ def check(conn, db, mnce): ) raise exception_inst res_check = int(disk_used) - return db.add_check(conn.get_addr_host(), 'disk', res_check) \ No newline at end of file + return res_check \ No newline at end of file diff --git a/app/modules/monitoring_modules/disk_snmp_linux.py b/app/modules/monitoring_modules/disk_snmp_linux.py index d5a584a..255b6df 100644 --- a/app/modules/monitoring_modules/disk_snmp_linux.py +++ b/app/modules/monitoring_modules/disk_snmp_linux.py @@ -7,10 +7,10 @@ unit = "%" connection = "snmp" -def check(conn, db, mnce): +def check(conn, mnce): oid = ".1.3.6.1.4.1.2021.9.1.7.1" total_space_on_disk = float(conn.exec_command(oid)) oid = ".1.3.6.1.4.1.2021.9.1.8.1" disk_used = float(conn.exec_command(oid)) percent_disk_used = round((disk_used * 100) / total_space_on_disk, 2) - return db.add_check(conn.get_addr_host(), part, percent_disk_used) \ No newline at end of file + return percent_disk_used \ No newline at end of file diff --git a/app/modules/monitoring_modules/load.py b/app/modules/monitoring_modules/load.py index ceadd21..49e7b66 100644 --- a/app/modules/monitoring_modules/load.py +++ b/app/modules/monitoring_modules/load.py @@ -8,7 +8,7 @@ unit = "" connection = "ssh" -def check(conn, db, mnce): +def check(conn, mnce): """ Returns the greatest between the user and system CPU charge """ @@ -24,4 +24,4 @@ def check(conn, db, mnce): field_load_avg = fields[i+3] field_load_avg = field_load_avg.replace(',', '.') load_avg = float(field_load_avg) - return db.add_check(conn.get_addr_host(), 'load', load_avg) \ No newline at end of file + return load_avg \ No newline at end of file diff --git a/app/modules/monitoring_modules/memory.py b/app/modules/monitoring_modules/memory.py index 27f8423..3f2a0ea 100644 --- a/app/modules/monitoring_modules/memory.py +++ b/app/modules/monitoring_modules/memory.py @@ -10,7 +10,7 @@ unit = "%" connection = "ssh" -def check(conn, db, mnce): +def check(conn, mnce): cmd = "cat /proc/meminfo" stdout = conn.exec_command(cmd) memfree = 0 @@ -28,4 +28,4 @@ def check(conn, db, mnce): ) raise exception_inst res_check = memused * 100 / int(memtotal) - return db.add_check(conn.get_addr_host(), "memory", res_check) \ No newline at end of file + return res_check \ No newline at end of file diff --git a/app/modules/monitoring_modules/memory_snmp_linux.py b/app/modules/monitoring_modules/memory_snmp_linux.py index 9459346..98b7e5c 100644 --- a/app/modules/monitoring_modules/memory_snmp_linux.py +++ b/app/modules/monitoring_modules/memory_snmp_linux.py @@ -7,10 +7,10 @@ unit = "%" connection = "snmp" -def check(conn, db, mnce): +def check(conn, mnce): oid = ".1.3.6.1.4.1.2021.4.5.0" total_mem = float(conn.exec_command(oid)) oid = ".1.3.6.1.4.1.2021.4.6.0" mem_used = float(conn.exec_command(oid)) percent_mem_used = round((mem_used * 100) / total_mem, 2) - return db.add_check(conn.get_addr_host(), part, percent_mem_used) \ No newline at end of file + return percent_mem_used \ No newline at end of file diff --git a/app/modules/monitoring_modules/ping.py b/app/modules/monitoring_modules/ping.py index 80883ae..a3da3c1 100644 --- a/app/modules/monitoring_modules/ping.py +++ b/app/modules/monitoring_modules/ping.py @@ -10,7 +10,7 @@ unit = "bool" connection = "" -def check(db, addr_host): +def check(addr_host): res_check = False try: child = pexpect.spawn('ping '+ addr_host + ' -c 1') @@ -24,4 +24,4 @@ def check(db, addr_host): except pexpect.TIMEOUT: res_check = False finally: - return db.add_check(addr_host, "ping", res_check) \ No newline at end of file + return res_check \ No newline at end of file diff --git a/app/modules/monitoring_modules/smtp.py b/app/modules/monitoring_modules/smtp.py index 80cb00f..bba24ff 100644 --- a/app/modules/monitoring_modules/smtp.py +++ b/app/modules/monitoring_modules/smtp.py @@ -8,11 +8,11 @@ part = "smtp" unit = "bool" connection = "" -def check(db, addr_host, smtp_port): +def check(addr_host, smtp_port): res_smtp_check = True try: s = smtplib.SMTP(addr_host, smtp_port) except Exception: res_smtp_check = False finally: - return db.add_check(addr_host, part, res_smtp_check) \ No newline at end of file + return res_smtp_check \ No newline at end of file diff --git a/app/modules/monitoring_modules/swap.py b/app/modules/monitoring_modules/swap.py index 696415a..c796578 100644 --- a/app/modules/monitoring_modules/swap.py +++ b/app/modules/monitoring_modules/swap.py @@ -8,7 +8,7 @@ unit = "%" connection = "ssh" -def check(conn, db, mnce): +def check(conn, mnce): cmd = "free -m" stdout = conn.exec_command(cmd) swap_total = 0 @@ -25,4 +25,4 @@ def check(conn, db, mnce): "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 + return res_swap \ No newline at end of file diff --git a/app/modules/monitoring_modules/swap_snmp_linux.py b/app/modules/monitoring_modules/swap_snmp_linux.py index cbb60a8..2e85f3d 100644 --- a/app/modules/monitoring_modules/swap_snmp_linux.py +++ b/app/modules/monitoring_modules/swap_snmp_linux.py @@ -7,10 +7,10 @@ unit = "%" connection = "snmp" -def check(conn, db, mnce): +def check(conn, mnce): oid = ".1.3.6.1.4.1.2021.4.3.0" total_swap = float(conn.exec_command(oid)) oid = ".1.3.6.1.4.1.2021.4.4.0" swap_used = total_swap - float(conn.exec_command(oid)) percent_swap_used = round( (swap_used * 100) / total_swap, 2) - return db.add_check(conn.get_addr_host(), part, percent_swap_used) \ No newline at end of file + return percent_swap_used \ No newline at end of file diff --git a/app/modules/monitoring_modules/updated_packages.py b/app/modules/monitoring_modules/updated_packages.py index 3717577..67be4e9 100644 --- a/app/modules/monitoring_modules/updated_packages.py +++ b/app/modules/monitoring_modules/updated_packages.py @@ -8,9 +8,9 @@ unit = "bool" connection = "ssh" -def check(conn, db, mnce): +def check(conn, mnce): cmd = "apt-get upgrade -s" stdout = conn.exec_command(cmd) tab_res = stdout.split(':') res_check = len(tab_res) <= 2 - return db.add_check(conn.get_addr_host(), "updated_packages", res_check) \ No newline at end of file + return res_check \ No newline at end of file diff --git a/app/modules/nmap_detection.py b/app/modules/nmap_detection.py index 0c08fb4..532d2db 100644 --- a/app/modules/nmap_detection.py +++ b/app/modules/nmap_detection.py @@ -8,7 +8,7 @@ from string import letters class nmap_detection: - def __init__(self, opt, db, ws, list_mod_conn, dict_mod_monitoring, known_ports, hnfe): + def __init__(self, opt, db, ws, list_mod_conn, dict_mod_monitoring, hnfe): self.opt = opt self.db = db self.ws = ws @@ -16,7 +16,6 @@ class nmap_detection: self.scanned_ip = [] self.list_mod_conn = list_mod_conn self.dict_mod_monitoring = dict_mod_monitoring - self.known_ports = known_ports self.HostNotFoundException = hnfe # function for splitting the different ranges of the IP adress @@ -170,6 +169,5 @@ class nmap_detection: self.db.add_host(dict_host['addr'], json.dumps(dict_host), self.list_mod_conn, - self.dict_mod_monitoring, - self.known_ports) + self.dict_mod_monitoring) self.scanned_ip.append(dict_host['addr']) \ No newline at end of file diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 2e7f768..290d35d 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -150,7 +150,7 @@ class shelve_db: finally: self.close_db() - def add_host(self, addr_host, nmap_res, conn_infos, dict_mod_info, known_ports): + def add_host(self, addr_host, nmap_res, conn_infos, dict_mod_info): """ Called by the nmap_detection module or directly by the module loader if no detection was asked. Add and save a new host after its first nmap detection @@ -175,9 +175,6 @@ class shelve_db: # Preconfiguration self.db["hosts"][addr_host]["conf"] = {} nmap_res_data = json.loads(nmap_res) - nmap_res_data['openports'] = self.check_if_known_port_is_open(addr_host, - known_ports, - nmap_res_data['openports']) self.db["hosts"][addr_host]['detected']['nmap'] = json.dumps(nmap_res_data) self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, conn_infos) os_host = nmap_res_data['os'] @@ -204,40 +201,6 @@ class shelve_db: self.close_db() @staticmethod - def check_if_known_port_is_open(addr_host, known_ports, openports): - """ - For each known_port that may not be detected by nmap, we will try to verify if this port is open or not by - opening a socket. - :param addr_host: the IP address of the host - :param known_ports: a list containing integers representing the known_ports to verify. - :param openports: a dictionary containing the nmap result of the detected open ports - :return: openports attribute with new fields for each open port newly verified. - """ - new_port_dict_list = [] - try: - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - for port_id in known_ports: - print port_id - port_id_was_detected = False - for port_dict in openports: - if port_dict['portid'] == port_id: - print 1 - port_id_was_detected = True - if not port_id_was_detected: - try: - if sock.connect_ex((addr_host, port_id)) == 0: - print 2 - new_port_dict_list.append({"portname": "", "portid": port_id}) - except Exception: - pass - print new_port_dict_list - for new_port_dict in new_port_dict_list: - openports.append(new_port_dict) - print openports - finally: - return openports - - @staticmethod def init_conn(dict_nmap_res, conn_infos): """ Returns an initialization for the connection configuration on a host. @@ -906,7 +869,7 @@ class shelve_db: title = "[Mum] " + status + " for " + addr_host + " " + moni_mod msg = "Mum reported a " + status + " value from the " + moni_mod + " module. " msg += "The following users will be notified: " - msg += self.db['hosts'][addr_host]['subscribers'] + msg += str(self.db['hosts'][addr_host]['conf']['subscribers']) dict_notif = {} notif_type = "" if status == 'warning': diff --git a/app/mum.py b/app/mum.py index dc79af3..a9bcd3e 100755 --- a/app/mum.py +++ b/app/mum.py @@ -178,7 +178,7 @@ def receive(ws): ml.set_conf_moni_mod(msg["SET_CONF_MOD"]) elif code == "CHECK_NOW": # asekd from hostpage args = msg["CHECK_NOW"] - ml.run_one_monitoring_module(args['mod_name'], args['addr_host'], None, None) + ml.run_one_monitoring_module(args['mod_name'], args['addr_host']) elif code == "GET_KEYS_LIST": # asked from hostpage, at the connection configuration ws.send(json.dumps({"KEYS_LIST": ml.get_public_keys_list()})) elif code == "TASK_LIST": diff --git a/app/process_monitoring.py b/app/process_monitoring.py index 9085da7..efafd13 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -132,12 +132,7 @@ class RunMonitoring(threading.Thread): def run(self): sys.stdout.flush() for dict_mod in self.list_dict_mod: - if dict_mod['mod_name'] == 'ping': - print "Launching " + str(dict_mod['mod_name']) + " request on " + str(dict_mod['addr']) - sys.stdout.flush() - self.ml.run_one_monitoring_module(dict_mod['mod_name'], dict_mod['addr'], None, None) - else: - print "Launching " + str(dict_mod['mod_name']) + " on " + str(dict_mod['addr']) - sys.stdout.flush() - self.ml.run_one_monitoring_module(dict_mod['mod_name'], dict_mod['addr'], None, None) + #print "Launching " + str(dict_mod['mod_name']) + " on " + str(dict_mod['addr']) + sys.stdout.flush() + self.ml.run_one_monitoring_module(dict_mod['mod_name'], dict_mod['addr']) self.wsc.notify_state_change() \ No newline at end of file diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index 6b5ffc9..8fab9e6 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -14,7 +14,7 @@ mumApp.controller('dashboardCtrl', function($scope, $filter, $routeParams, DataH "name":"www.example.com", "status":val, //"success" or "warning" or "danger" or "" "group":[ "all", ...], - "last_check":val //UNIX time + "last_check":string "subscribers":{ "uid":val, "priority":val diff --git a/views/dashboard.html b/views/dashboard.html index b50abb6..e3bfb08 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -69,7 +69,7 @@ <tbody> <tr ng-repeat="item in items | orderBy:sort.sortingOrder:sort.reverse | - filter:{addr:addr_filter, name:name_filter, group:filtering_group} | + filter:{addr:addr_filter, name:name_filter, group:group_filter} | filter:filtering_status" class={{item.status}}> <!-- group.name:group_filter --> <td><a href="#/hostpage/{{item.addr}}">{{item.addr}}</a></td> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm