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 42f139eb058b718aa9f5824130bbe80e4b259a6f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 8 10:54:17 2015 +0200 hostpage: unit of value visible on table --- app/modules/monitoring_modules/load.py | 2 +- app/mum.py | 6 +-- static/js/controllers/headCtrl.js | 3 -- static/js/controllers/hostPageCtrl.js | 77 ++++++++++++++++++++-------------- views/hostpage.html | 2 +- 5 files changed, 50 insertions(+), 40 deletions(-) diff --git a/app/modules/monitoring_modules/load.py b/app/modules/monitoring_modules/load.py index 29743aa..a85427f 100644 --- a/app/modules/monitoring_modules/load.py +++ b/app/modules/monitoring_modules/load.py @@ -3,7 +3,7 @@ __author__ = 'aguilbaud' compatible_os = ['linux', 'unix'] block = "hardware" -unit = "15 min load average" +unit = "" def check(conn, db, mnce): diff --git a/app/mum.py b/app/mum.py index 321373f..2a9e06a 100755 --- a/app/mum.py +++ b/app/mum.py @@ -134,7 +134,9 @@ def receive(ws): db = ml.get_db() ws.send(json.dumps({"RES_GET_HOSTS": db.get_hosts()})) elif code == "GET_HOST_INFO": # asked from hostpage - ws.send(json.dumps({"RES_INFO_HOST": ml.get_host_info(msg["GET_HOST_INFO"])})) + dict_host_info = ml.get_host_info(msg["GET_HOST_INFO"]) + dict_host_info['loaded_moni_mod'] = ml.get_info_mod_monitoring() + ws.send(json.dumps({"RES_INFO_HOST": dict_host_info})) elif code == "REM_HOST": ml.remove_host(msg["REM_HOST"]) ws.send(json.dumps({"RES_REM_HOST": True})) @@ -147,8 +149,6 @@ def receive(ws): ws.send(msg) elif code == "GET_LOADED_CONN_MOD": # asked from hostpage, at the connection configuration ws.send(json.dumps({"RES_GET_LOADED_CONN_MOD": ml.get_info_mod_conn()})) - elif code == "GET_LOADED_MONI_MOD": # asked from hostpage, at the block activation conf - ws.send(json.dumps({"RES_GET_LOADED_MONI_MOD": ml.get_info_mod_monitoring()})) elif code == "GET_LOADED_NOTIF_MOD": # asekd from notification parameters page ws.send(json.dumps({"RES_GET_LOADED_NOTIF_MOD": ml.get_info_mod_notification()})) elif code == "GET_ALL_SUBSCRIPTIONS": # asekd from notification parameters page diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index d57023e..4e63e29 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -47,9 +47,6 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r case "RES_GET_LOADED_CONN_MOD": $rootScope.$broadcast("resGetLoadedConnMod", obj[key]); break; - case "RES_GET_LOADED_MONI_MOD": - $rootScope.$broadcast("resGetLoadedMoniMod", obj[key]); - break; case "RES_GET_LOADED_NOTIF_MOD": $rootScope.$broadcast("resGetLoadedNotifMod", obj[key]); break; diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 2cd251a..f69c0b3 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -7,7 +7,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar // asks for host informations $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOST_INFO": $routeParams.param})); - $scope.items = [];/* result of get_host_informations => + $scope.items = {};/* result of get_host_informations => { "interventions":list, "detected": @@ -33,6 +33,15 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar }, "custom_infos":val "compatible_os_list": [os1, os2, ...] + "loaded_moni_mod": + { + mod_name: + { + 'compatible_os': [val1, val2, ...], => a list containing the compatibles os + 'unit': val, => the unit type of return ('%', 'bool' or other) + 'block': val, => the monitoring block of the module + } + } } */ $scope.update_os_name = function(){ @@ -42,6 +51,14 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_os_name', 'args': args}})); }; + $scope.get_unit = function(mod_name){ + res = ''; + if($scope.items.loaded_moni_mod[mod_name].unit != 'bool'){ + res = $scope.items.loaded_moni_mod[mod_name].unit; + } + return res; + } + $scope.$on("resCall", function (event, args) { if(args.func == 'update_os_name'){ $route.reload(); @@ -167,7 +184,8 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar block_args: function(){ return {'addr_host' : $scope.addr_host, 'activated_mod': $scope.items['activated_monitoring'], - 'os_host': $scope.items.detected.nmap.os}; + 'os_host': $scope.items.detected.nmap.os, + 'loaded_moni_mod': $scope.items.loaded_moni_mod}; } } }); @@ -448,16 +466,18 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal 'activated_mod':{ mod_name: bool }, - 'os_host': val */ - - $scope.loaded_moni_mods = {}; /* { - mod_name: - { - 'compatible_os': [val1, val2, ...], => a list containing the compatibles os - 'unit': val, => the unit type of return ('%', 'bool' or other) - 'block': val, => the monitoring block of the module - } - } */ + 'os_host': val, + "loaded_moni_mod": + { + mod_name: + { + 'compatible_os': [val1, val2, ...], => a list containing the compatibles os + 'unit': val, => the unit type of return ('%', 'bool' or other) + 'block': val, => the monitoring block of the module + } + } + } + */ $scope.blocks = {}; /* block_name: @@ -470,26 +490,19 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal } */ - $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_MONI_MOD": ""})); - - $scope.$on("resGetLoadedMoniMod", function (event, args) { - $scope.$apply(function(){ - $scope.loaded_moni_mods = args; - for(mod in args){ - var activated = false; - var block = args[mod]['block']; - if($scope.block_args['activated_mod'].hasOwnProperty(mod)) { // if the module is known by the host - if($scope.block_args['activated_mod'][mod]){ // if the module is activated - activated = true; - } - } - if(!$scope.blocks.hasOwnProperty(block)){ - $scope.blocks[block] = []; - } - $scope.blocks[block][$scope.blocks[block].length] = {modname: mod, activated: activated}; + for(mod in $scope.block_args.loaded_moni_mod){ + var activated = false; + var block = $scope.block_args.loaded_moni_mod[mod]['block']; + if($scope.block_args.activated_mod.hasOwnProperty(mod)) { // if the module is known by the host + if($scope.block_args.activated_mod[mod]){ // if the module is activated + activated = true; } - }); - }); + } + if(!$scope.blocks.hasOwnProperty(block)){ + $scope.blocks[block] = []; + } + $scope.blocks[block][$scope.blocks[block].length] = {modname: mod, activated: activated}; + } $scope.select_all = function(block){ for(mod in block){ @@ -504,7 +517,7 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal }; $scope.is_not_compatible = function(modname){ - return $scope.loaded_moni_mods[modname]['compatible_os'].lastIndexOf($scope.block_args.os_host) < 0; + return $scope.block_args.loaded_moni_mod[modname].compatible_os.lastIndexOf($scope.block_args.os_host) < 0; }; $scope.ok = function () { diff --git a/views/hostpage.html b/views/hostpage.html index cee03c9..45330fe 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -24,7 +24,7 @@ class={{item.state}} ng-show="items.activated_monitoring[itemname]"> <td>{{itemname}}</td> - <td>{{item.value}}</td> + <td>{{item.value}} {{get_unit(itemname)}}</td> <td>{{item.state}}</td> <td>{{item.date.split('.')[0]}}</td> <td><button type="button" class="btn btn-primary btn-xs" -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.