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 b1f49077b42b54b817c18c0bce0c395f9f431c33 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 29 10:53:26 2015 +0200 hostpage: detected configuration separated from nmap detection. subparts can be checked from the detected config, and the monitoring will check the selected subparts --- app/modules/detection_modules/drive_detection.py | 3 ++- app/modules/detection_modules/drive_snmp_linux.py | 14 +++++++++++ app/modules/storage_modules/shelve_db.py | 27 +++++++++++++++++---- static/js/controllers/hostPageCtrl.js | 21 +++++++++++++++- views/hostpage.html | 29 ++++++++++++++++++----- 5 files changed, 82 insertions(+), 12 deletions(-) diff --git a/app/modules/detection_modules/drive_detection.py b/app/modules/detection_modules/drive_detection.py index 2f34fce..be02ae1 100644 --- a/app/modules/detection_modules/drive_detection.py +++ b/app/modules/detection_modules/drive_detection.py @@ -3,6 +3,7 @@ import json compatible_os = ['linux', 'unix'] connection = "ssh" +part = 'disk' def run_detection(conn, db): @@ -32,4 +33,4 @@ def run_detection(conn, db): # meilleur nom pour chaque attribut ? dict_total[dict_drive["name"]] = dict_drive i += 1 - db.save_detection(conn.get_addr_host(), "drive_detection", json.dumps(dict_total)) \ No newline at end of file + db.save_detection(conn.get_addr_host(), part, json.dumps(dict_total)) \ No newline at end of file diff --git a/app/modules/detection_modules/drive_snmp_linux.py b/app/modules/detection_modules/drive_snmp_linux.py new file mode 100644 index 0000000..9faa53b --- /dev/null +++ b/app/modules/detection_modules/drive_snmp_linux.py @@ -0,0 +1,14 @@ +__author__ = 'aguilbaud' +import json + +compatible_os = ['linux', 'unix'] +connection = "snmp_walk" +part = 'disk' + +def run_detection(conn, db): + oid_mounted_partitions = "1.3.6.1.4.1.2021.9.1.2" + mounted_partitions = conn.exec_command(oid_mounted_partitions) + partition_list = [] + for partition in mounted_partitions: + partition_list.append(mounted_partitions[partition]) + db.save_detection(conn.get_addr_host(), part, json.dumps(partition_list)) \ 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 25b4dbd..344dc7c 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -177,6 +177,25 @@ class shelve_db: self.close_db() return res + def set_subpart(self, args): + """ + Asked from the hostpage. Set the subpart list to monitore. + :param args: A dictionary containing: + { + 'addr_host': str, + 'modname': str, + 'subpart_list': [str, str, ...] + } + """ + self.open_db() + try: + self.db['hosts'][args['addr_host']]['conf']['monitoring'][args['modname']]['subparts'] = \ + args['subpart_list'] + except Exception: + print traceback.format_exc() + finally: + self.close_db() + 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. @@ -868,12 +887,12 @@ class shelve_db: new_status = 'success' else: # if numerical value - if val >= minor_limit: + if val >= int(minor_limit): # if value is above waning limit new_status = 'warning' - elif val >= major_limit: - # if value is above danger limit - new_status = 'danger' + if val >= int(major_limit): + # if value is above danger limit + new_status = 'danger' else: new_status = 'success' if 'state' in dict_val: diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 137437d..3d4f675 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -48,6 +48,8 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $scope.collapsed = {}; + $scope.subparts_checked = {}; + $scope.update_nmap_attribute = function(attribute, new_value){ var args = {}; args['attribute'] = attribute; @@ -56,6 +58,19 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_nmap_attribute', 'args': args}})); }; + $scope.save_subpart = function(modname){ + var args = {}; + args['addr_host'] = $scope.addr_host; + args['modname'] = modname; + args['subpart_list'] = []; + for(key in $scope.subparts_checked[modname]){ + if($scope.subparts_checked[modname][key]){ + args['subpart_list'].push(key); + } + } + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'set_subpart', 'args': args}})); + } + $scope.get_unit = function(mod_name){ res = ''; if($scope.items.loaded_moni_mod[mod_name].unit != 'bool'){ @@ -131,8 +146,12 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $scope.model.custom_infos = args.custom_infos; $scope.loaded = true; $scope.model['compatible_os_list'] = args['compatible_os_list']; - for(modname in args.monitoring){ + for(var modname in args.monitoring){ $scope.collapsed[modname] = true; + $scope.subparts_checked[modname] = {} + for(var key in args.detected[modname]){ + $scope.subparts_checked[modname][args.detected[modname][key]] = false; + } } } else{ // we takes only monitoring updates diff --git a/views/hostpage.html b/views/hostpage.html index 0226772..ea883ef 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -64,13 +64,9 @@ </tbody> </table> <accordion close-others="false"> - <accordion-group heading="Detected Configuration"> + <accordion-group heading="Essential configuration (nmap detection)"> <table class="table table-bordered table-hover"> - <tr ng-repeat-start="(modname, mod) in items.detected"> - <th>{{modname}}</th> - </tr> - <tr ng-repeat-end - ng-repeat="(key, val) in mod"> + <tr ng-repeat="(key, val) in items.detected.nmap"> <td>{{key}}</td> <td>{{val}}</td> <td ng-show="(key == 'os')"> @@ -97,6 +93,27 @@ </tr> </table> </accordion-group> + <accordion-group heading="Detected configuration (select the subparts to monitore here)"> + <table class="table table-bordered table-hover"> + <tr ng-repeat-start="(modname, mod) in items.detected" + ng-show="modname != 'nmap'"> + <th>{{modname}}</th> + <th> + <button type="button" class="btn btn-info btn-xs" + ng-click="save_subpart(modname)"> + Monitore selected subparts + </button> + </th> + </tr> + <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> + </table> + </accordion-group> <accordion-group heading="Custom informations"> <label for="custom_info">Add any information here :</label> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.