def handle(self): event = self.event alert = AlertGenerator(event) interface = event.get_subject() is_unresolved = unresolved.refers_to_unresolved_alert(event) if event.state == event.STATE_START: alert.alert_type = 'linkDegraded' if is_unresolved: return self._handle_duplicate(alert, is_unresolved) if not interface.is_degraded(): return self._ignore("Got aggregateLinkState start event, but " "the interface is not currently degraded.") elif event.state == event.STATE_END: alert.alert_type = 'linkRestored' if not is_unresolved: return self._ignore("Got aggregateLinkState end event, but " "there is no currently active alert to " "resolve.") if interface.is_degraded(): return self._ignore("Got aggregateLinkState end event, but the " "interface still appears to be degraded.") if self._box_is_on_maintenance(): alert.post_alert_history() else: alert.post() event.delete()
def _post_alert(self, event): alert = AlertGenerator(event) alert.alert_type = ('exceededThreshold' if event.state == event.STATE_START else 'belowThreshold') if alert.is_event_duplicate(): self._logger.info('Ignoring duplicate alert') else: alert.post()
def _post_alert(self, event): alert = AlertGenerator(event) alert.alert_type = ('onMaintenance' if event.state == event.STATE_START else 'offMaintenance') alert.history_vars = dict(alert) if alert.is_event_duplicate(): self._logger.info('Ignoring duplicate event') else: alert.post()
def _post_alert(self, event): alert = AlertGenerator(event) alert.alert_type = ( 'onMaintenance' if event.state == event.STATE_START else 'offMaintenance') alert.history_vars = dict(alert) if alert.is_event_duplicate(): self._logger.info('Ignoring duplicate event') else: alert.post()
def _post_alert(self, event): alert = AlertGenerator(event) alert.alert_type = ( 'exceededThreshold' if event.state == event.STATE_START else 'belowThreshold') if alert.is_event_duplicate(): self._logger.info('Ignoring duplicate alert') else: alert.post()
def _post_generic_alert(self, event): alert = AlertGenerator(event) if 'alerttype' in event.varmap: alert.alert_type = event.varmap['alerttype'] is_stateless = event.state == Event.STATE_STATELESS if is_stateless or not alert.is_event_duplicate(): self._logger.debug('Posting %s event', event.event_type) alert.post() else: self._logger.info('Ignoring duplicate %s event' % event.event_type) event.delete()
def handle(self): event = self.event alert = AlertGenerator(event) if event.state in [event.STATE_START, event.STATE_END]: service = self._update_service() self._set_alert_type(alert, service) self._populate_alert(alert) alert.post(post_alert=not self._box_is_on_maintenance()) event.delete()
def _post_down_warning(self): """Posts the actual warning alert""" alert = AlertGenerator(self.event) alert.state = self.event.STATE_STATELESS shadow = self._verify_shadow() if shadow: alert.alert_type = 'boxShadowWarning' self._set_internal_state(Netbox.UP_SHADOW) else: alert.alert_type = 'boxDownWarning' self._logger.info("%s: Posting %s alert", self.event.netbox, alert.alert_type) alert.post()
def handle(self): event = self.event alert = AlertGenerator(event) if event.state in [event.STATE_START, event.STATE_END]: service = self._update_service() self._set_alert_type(alert, service) self._populate_alert(alert) if self._box_is_on_maintenance(): alert.post_alert_history() else: alert.post() event.delete()
def _post_generic_alert(self, event): alert = AlertGenerator(event) if 'alerttype' in event.varmap: alert.alert_type = event.varmap['alerttype'] is_stateless = event.state == Event.STATE_STATELESS if is_stateless or not alert.is_event_duplicate(): if self._box_is_on_maintenance(event): self._logger.debug('%s is on maintenance, only posting to ' 'alert history for %s event', event.netbox, event.event_type) alert.post_alert_history() else: self._logger.debug('Posting %s event', event.event_type) alert.post() else: self._logger.info('Ignoring duplicate %s event for %s', event.event_type, event.netbox) self._logger.debug('ignored alert details: %r', event) event.delete()