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 1f8df6fc24d1b8899a3ec1965ddf583ba2ca691d Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 29 11:52:16 2015 +0200 hostpage: checkboxes of subparts selected by the saved conf + http module returns a dict --- app/modules/monitoring_modules/http.py | 20 ++++++++++---------- app/modules/monitoring_modules/smtp.py | 23 ++++++++++++----------- app/modules/storage_modules/shelve_db.py | 5 ++++- static/js/controllers/hostPageCtrl.js | 4 ++-- views/hostpage.html | 1 - 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/app/modules/monitoring_modules/http.py b/app/modules/monitoring_modules/http.py index 07fb16a..0ef3cbe 100644 --- a/app/modules/monitoring_modules/http.py +++ b/app/modules/monitoring_modules/http.py @@ -11,21 +11,21 @@ return_dict = False def check(addr_host, port_list, cnfe): - res_http_check = False + res_http_check = {} http_port_found = False for i in range(len(port_list)): # for each http port detected for this host - try: - if port_list[i]['portname'] == part: - http_port_found = True + if port_list[i]['portname'] == part: + http_port_found = True + try: # the result of the check is true if urlopen returns the http code 200 - res_http_check = urllib2.urlopen("http://" + addr_host + ":" + str(port_list[i]['portid']), - None, - 10 - ).getcode() == 200 - except Exception: - return False + res_http_check[port_list[i]['portid']] = urllib2.urlopen("http://" + addr_host + ":" + str(port_list[i]['portid']), + None, + 10 + ).getcode() == 200 + except Exception: + res_http_check[port_list[i]['portid']] = False if not http_port_found: # if there is no http port detected for this host exception_inst = getattr(cnfe, "CommandNotFoundException")( diff --git a/app/modules/monitoring_modules/smtp.py b/app/modules/monitoring_modules/smtp.py index a2e466b..a6f19b9 100644 --- a/app/modules/monitoring_modules/smtp.py +++ b/app/modules/monitoring_modules/smtp.py @@ -7,30 +7,31 @@ block = "network" part = "smtp" unit = "bool" connection = "" -return_dict = False +return_dict = True def check(addr_host, port_list, cnfe): - res_smtp_check = False smtp_port_found = False + res_check = {} for i in range(len(port_list)): - try: - # for each smtp port detected for this host - if port_list[i]['portname'] == part: - smtp_port_found = True - # try to connect to this port, with a timeout of 10 seconds + # for each smtp port detected for this host + if port_list[i]['portname'] == part: + smtp_port_found = True + # try to connect to this port, with a timeout of 10 seconds + try: smtp_conn_inst = smtplib.SMTP(addr_host, int(port_list[i]['portid']), 10) # send a HELO request and should return a tuple with 250 as first member if OK - res_smtp_check = smtp_conn_inst.helo()[0] == 250 + res_check[port_list[i]['portid']] = smtp_conn_inst.helo()[0] == 250 # close the connection when finished smtp_conn_inst.quit() - except Exception: - return False + except Exception: + res_check[port_list[i]['portid']] = False + if not smtp_port_found: # if there is no smtp port detected for this host exception_inst = getattr(cnfe, "CommandNotFoundException")( part, addr_host ) raise exception_inst - return res_smtp_check + return res_check diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 344dc7c..5dc918a 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -436,9 +436,10 @@ class shelve_db: "value":string } }, - 'activated_monitoring':{ + "activated_monitoring":{ mod_name: bool }, + 'subparts": [str, ...] "custom_infos":string "status": string } @@ -456,8 +457,10 @@ class shelve_db: for mod in self.db['hosts'][addr_host]['detected']: res['detected'][mod] = json.loads(self.db['hosts'][addr_host]['detected'][mod]) res['activated_monitoring'] = {} + res['subparts'] = {} for mod in self.db['hosts'][addr_host]['conf']['monitoring']: res['activated_monitoring'][mod] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['activated'] + res['subparts'][mod] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['subparts'] res['custom_infos'] = self.db['hosts'][addr_host]['conf']['custom_info'] res['interventions'] = self.db['hosts'][addr_host]['conf']['interventions'] res['status'] = self.db['hosts'][addr_host]['status']['state'] diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 3d4f675..d9cf99f 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -150,11 +150,11 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $scope.collapsed[modname] = true; $scope.subparts_checked[modname] = {} for(var key in args.detected[modname]){ - $scope.subparts_checked[modname][args.detected[modname][key]] = false; + $scope.subparts_checked[modname][args.detected[modname][key]] = args.subparts[modname].hasOwnProperty(key); } } } - else{ // we takes only monitoring updates + else{ // we take only monitoring updates $scope.items.monitoring = args.monitoring; $scope.items.status = args.status; } diff --git a/views/hostpage.html b/views/hostpage.html index ea883ef..c572372 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -108,7 +108,6 @@ <tr ng-repeat-end ng-repeat="(key, val) in mod" ng-show="modname != 'nmap'"> - <td>{{key}}</td> <td>{{val}}</td> <td><input type="checkbox" ng-model="subparts_checked[modname][val]"></td> </tr> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.