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 a1be3490ba19ad24828bac217df042d6fe8b15d1 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Jun 19 17:50:34 2015 +0200 consecutive failures per modules + replaced glyphicons to awesomefonts --- app/modules/storage_modules/shelve_db.py | 35 ++++++++++++++++++-------------- bower.json | 3 ++- views/dashboard.html | 32 ++++++++++++++++++++++------- views/hostpage.html | 10 ++++----- views/index.html | 5 +++-- 5 files changed, 55 insertions(+), 30 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index a5a9a0d..609b71d 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -263,9 +263,6 @@ class shelve_db: self.db["hosts"][addr_host]["archive"] = {} self.db["hosts"][addr_host]["stats"] = {} #self.db["hosts"][addr_host]['param']['port'] = nmap_res_data['openports'] - # set the initial number of failures to 0 - self.db['hosts'][addr_host]['status']['nb_warning'] = 0 - self.db['hosts'][addr_host]['status']['nb_danger'] = 0 except Exception: self.logger.error(traceback.format_exc()) finally: @@ -495,11 +492,6 @@ class shelve_db: res['interventions'] = self.db['hosts'][addr_host]['conf']['interventions'] res['status'] = self.db['hosts'][addr_host]['status']['state'] res['display_name'] = self.db['hosts'][addr_host]['conf']['display_name'] - res['nb_warning'] = self.db['hosts'][addr_host]['status']['nb_warning'] - res['nb_danger'] = self.db['hosts'][addr_host]['status']['nb_danger'] - # we reset here the number of failures sent - self.db['hosts'][addr_host]['status']['nb_warning'] = 0 - self.db['hosts'][addr_host]['status']['nb_danger'] = 0 except Exception: self.logger.error(traceback.format_exc()) finally: @@ -890,7 +882,7 @@ class shelve_db: def add_check(self, addr_host, mod_name, val): """ - Called by a monitoring module. + Called by the module loader after calling a monitoring module. Add a new check of a host from a specific module. Add the previous entry of monitoring to the archive and call update_stats to update the statistics. :param addr_host: the IP adress of the host checked @@ -904,13 +896,20 @@ class shelve_db: """ dict_notif = {} self.open_db() - dict_new_val = {"date": str(datetime.now()), "value": val} try: if mod_name not in self.db['hosts'][addr_host]["monitoring"]: # creating the monitoring structure for this module if not exists self.db['hosts'][addr_host]["monitoring"][mod_name] = {} + self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_warning'] = 0 + self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_danger'] = 0 self.db['hosts'][addr_host]['stats'][mod_name] = {} self.db['hosts'][addr_host]['archive'][mod_name] = {} + + dict_new_val = {"date": str(datetime.now()), + "value": val, + "nb_warning": self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_warning'], + "nb_danger": self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_danger']} + if isinstance(val, type({})): # if dictionary for key in val: @@ -923,9 +922,11 @@ class shelve_db: dict_new_val, self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'], self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit']) + self.db['hosts'][addr_host]['monitoring'][mod_name] = dict_new_val # updating the global state of the host self.db['hosts'][addr_host]['status']['date'] = dict_new_val['date'] + if 'state' not in self.db['hosts'][addr_host]['status']: self.db['hosts'][addr_host]['status']['state'] = dict_new_val['state'] else: @@ -938,13 +939,17 @@ class shelve_db: and not state == 'danger': state = 'warning' self.db['hosts'][addr_host]['status']['state'] = state + # create a notification structure if the state is not a success - if not dict_new_val['state'] == 'success': - # incrementation of the number of corresponding failures - self.db['hosts'][addr_host]['status']['nb_' + dict_new_val['state']] += 1 - #print mod_name - #print self.db['hosts'][addr_host]['status']['nb_' + dict_new_val['state']] + if dict_new_val['state'] != 'success': dict_notif = self.create_notif_structure(addr_host, mod_name, dict_new_val['state']) + # incrementation of the consecutive fails nunmber for this module + self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_'+dict_new_val['state']] += 1 + else: + # we set the consecutive fail number to 0 + self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_warning'] = 0 + self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_danger'] = 0 + # updating and saving statistics self.db['hosts'][addr_host]['stats'][mod_name] = \ self.update_stats(self.db['hosts'][addr_host]['stats'][mod_name], val) diff --git a/bower.json b/bower.json index f6eac69..24356a2 100644 --- a/bower.json +++ b/bower.json @@ -10,7 +10,8 @@ "angular-file-upload": "~1.1.5", "angular-charts": "~0.2.7", "angular-ui-select": "~0.12.0", - "angular-sanitize": "1.2.28" + "angular-sanitize": "1.2.28", + "fontawesome": "~4.3.0" }, "resolutions": { "angular": "~1.2.28", diff --git a/views/dashboard.html b/views/dashboard.html index e08a364..5713e93 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -121,7 +121,13 @@ popover="{{host.nb_subscribers}} subscribers" popover-trigger="mouseenter" ng-click="open_modal_notif(host.addr, null)"> - <span class="glyphicon glyphicon-user" aria-hidden="true"> + <span class="fa fa-user" + aria-hidden="true" + ng-show="host.nb_subscribers > 0"> + </span> + <span class="fa fa-user-times" + aria-hidden="true" + ng-show="host.nb_subscribers == 0"> </span> </button> </td> @@ -133,7 +139,8 @@ popover-placement="top" popover="Add a machine" popover-trigger="mouseenter"> - <span class="glyphicon glyphicon-plus" aria-hidden="true"> + <span class="fa fa-plus" + aria-hidden="true"> </span> </button> </a> @@ -174,13 +181,21 @@ </td> <td>{{group.status}}</td> <td> - <button type="button" class="btn btn-{{get_group_sub_num(groupname).btn_type}} btn-xs" aria-label="Subscribers" + <button type="button" + class="btn btn-{{get_group_sub_num(groupname).btn_type}} btn-xs" + aria-label="Subscribers" popover-placement="left" popover="{{get_group_sub_num(groupname).nb_sub}} subscribers" popover-trigger="mouseenter" ng-click="open_modal_notif(null, groupname)" ng-show="groupname != 'all'"> - <span class="glyphicon glyphicon-user" aria-hidden="true"> + <span class="fa fa-user" + aria-hidden="true" + ng-show="get_group_sub_num(groupname).nb_sub > 0"> + </span> + <span class="fa fa-user-times" + aria-hidden="true" + ng-show="get_group_sub_num(groupname).nb_sub == 0"> </span> </button> </td> @@ -223,7 +238,8 @@ class="btn btn-danger btn-xs" aria-label="Remove notification instruction" ng-click="remove_notif(username, 'minor', minor_notif_name)"> - <span class="glyphicon glyphicon-minus" aria-hidden="true"></span> + <span class="fa fa-minus" + aria-hidden="true"></span> </button> </li> <li ng-repeat="(major_notif_name, major_notif_obj) in subscriber.major" @@ -233,7 +249,8 @@ class="btn btn-danger btn-xs" aria-label="Remove notification instruction" ng-click="remove_notif(username, 'major', major_notif_name)"> - <span class="glyphicon glyphicon-minus" aria-hidden="true"></span> + <span class="fa fa-minus" + aria-hidden="true"></span> </button> </li> </ul> @@ -276,7 +293,8 @@ aria-label="Add a notification rule" ng-click="add_notif()" ng-disabled="new_notif.priority==null || new_notif_type=='' || new_mod_notif=='' || new_username==''"> - <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> + <span class="fa fa-plus" + aria-hidden="true"></span> </button> </div> <div class="modal-footer"> diff --git a/views/hostpage.html b/views/hostpage.html index db09a91..7ac57f6 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -46,12 +46,11 @@ popover="{{popover_message()}}" popover-trigger="mouseenter" ng-click="set_idle_state()"> - <span class="glyphicon glyphicon-off" aria-hidden="true"> + <span class="fa fa-power-off" aria-hidden="true"> </span> </button> <div ng-show="get_idle_state() == 'success'"> - <p>There has been {{items.nb_warning}} warning(s) and {{items.nb_danger}} danger(s) consecutively.</p> <table class="table table-condensed table-hover" ng-show="items.status != 'idling'"> @@ -108,9 +107,10 @@ popover="Stop the monitoring of this part" popover-trigger="mouseenter" ng-click="update_module_activation(modname, false)"> - <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> + <span class="fa fa-times" aria-hidden="true"></span> </button> </td> + <td>{{mod.nb_warning}},{{mod.nb_danger}}</td> </tr> <tr ng-repeat-end ng-repeat="(valname, val) in mod.value" @@ -541,7 +541,7 @@ class="btn btn-danger" aria-label="Remove port" ng-click="remove_port(port_dict)"> - <span class="glyphicon glyphicon-minus" aria-hidden="true"></span> + <span class="fa fa-minus" aria-hidden="true"></span> </button> </td> </tr> @@ -569,7 +569,7 @@ id="add_port_btn" ng-click="add_port()" ng-disabled="new_portname == null || new_portid == null"> - <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> + <span class="fa fa-plus" aria-hidden="true"></span> </button> </div> </div> diff --git a/views/index.html b/views/index.html index 778506f..80d02a2 100644 --- a/views/index.html +++ b/views/index.html @@ -17,6 +17,7 @@ <link href="static/css/dashboard.css" rel="stylesheet"> <link href="bower_components/angular-toastr/dist/angular-toastr.min.css" rel="stylesheet"/> <link href="bower_components/angular-ui-select/dist/select.min.css" rel="stylesheet"/> + <link href="bower_components/fontawesome/css/font-awesome.css" rel="stylesheet"/> <!-- AngularJS --> <script src="bower_components/angular/angular.min.js"></script> @@ -68,7 +69,7 @@ popover-placement="bottom" popover="Add a machine" popover-trigger="mouseenter"> - <span class="glyphicon glyphicon-plus" aria-hidden="true"> + <span class="fa fa-plus" aria-hidden="true"> </span> </button> </a> @@ -79,7 +80,7 @@ popover-placement="bottom" popover="{{task_list}}" popover-trigger="mouseenter">Current tasks: {{format_task_list(task_list)}} - <span class="glyphicon glyphicon-collapse-down"></span> + <span class="fa fa-spinner fa-spin"></span> </p> </div> <div id="navbar" class="navbar-collapse collapse"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.