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 7501f04ad937446e5cb64fab00f63dc6bff80db6 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Mon Jul 6 10:17:41 2015 +0200 Service view on dashboard --- app/modules/storage_modules/shelve_db.py | 3 ++- static/js/controllers/dashboardCtrl.js | 33 +++++++++++++++++++++++++ views/dashboard.html | 42 +++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 309b0c7..7a729f3 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -452,7 +452,8 @@ class shelve_db: }, "warning": [mod_name, ...], "danger": [mod_name, ...], - "nb_subscribers": int + "nb_subscribers": int, + "display_name": str }, ... ] diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index 94577cc..a638747 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -14,6 +14,7 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r { "addr":"192.168.74.1", "name":"www.example.com", + "display_name": str, "status":val, //"success" or "warning" or "danger" or "" "group":[ "all", ...], "last_check":string @@ -236,4 +237,36 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r } } }; + + /*** SERVICE VIEW FUNCIONS ***/ + + $scope.service_obj = {}; /* {mod_name: {'warning': [addr, ...], 'danger': [addr, ...]}, ...} */ + + $scope.is_services_in_alert = function (){ + return Object.keys($scope.service_obj).length > 0; + }; + + $scope.update_service_obj = function (){ + for (var i = 0, l=$scope.items.length; i<l; i++){ + tab_warning = $scope.items[i].warning; + for (var j = 0, l_warn = tab_warning.length; j<l_warn; j++){ + if(!$scope.service_obj.hasOwnProperty(tab_warning[j])){ + $scope.service_obj[tab_warning[j]] = {}; + $scope.service_obj[tab_warning[j]].warning = []; + $scope.service_obj[tab_warning[j]].danger = []; + } + $scope.service_obj[tab_warning[j]].warning.push($scope.items[i].display_name); + } + + tab_danger = $scope.items[i].danger; + for (var j = 0, l_dang = tab_danger.length; j<l_dang; j++){ + if(!$scope.service_obj.hasOwnProperty(tab_danger[j])){ + $scope.service_obj[tab_danger[j]] = {}; + $scope.service_obj[tab_danger[j]].warning = []; + $scope.service_obj[tab_danger[j]].danger = []; + } + $scope.service_obj[tab_danger[j]].danger.push($scope.items[i].display_name); + } + } + }; }); \ No newline at end of file diff --git a/views/dashboard.html b/views/dashboard.html index 18ec320..96eefcf 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -15,13 +15,14 @@ <div ng-show="!fullscreen"> <input type="radio" value="host_view" ng-model="view"> Host view <input type="radio" value="group_view" ng-model="view" ng-click="update_group_obj()"> Group view + <input type="radio" value="service_view" ng-model="view" ng-click="update_service_obj()"> Service view </div> <!-- Host view --> <div ng-show="view == 'host_view' && items.length > 0"> <h2 class="sub-header" - ng-show="!fullscreen">Hosts currently on monitoring</h2> + ng-show="!fullscreen">Machines under monitoring...</h2> <div class="row" ng-show="items.length > 0"> <div ng-show="!fullscreen"> @@ -262,6 +263,45 @@ </div> </div> + <!-- Service View --> + + <div ng-show="view == 'service_view' && items.length > 0"> + <div ng-show="is_services_in_alert()"> + <h2 class="sub-header">Services in alert...</h2> + + <table class="table table-condensed table-hover"> + <thead> + <tr> + <th>Service</th> + <th>Machines in alert</th> + </tr> + </thead> + + <tbody> + <tr ng-repeat="(mod_name, mod) in service_obj"> + <td> + {{mod_name}} + </td> + <td> + <span ng-repeat="machine in mod.danger" + style="color:red"> + {{machine}} <br/> + </span> + <span ng-repeat="machine in mod.warning" + style="color:orange"> + {{machine}} <br/> + </span> + </td> + </tr> + </tbody> + </table> + </div> + + <div ng-show="!is_services_in_alert()"> + <h2 class="sub-header">No services in alert at the moment.</h2> + </div> + </div> + <!-- Message when no hosts on monitoring --> <div ng-show="items.length == 0"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.