Exemple #1
0
 def _get_up_alert(self):
     alert = AlertGenerator(self.event)
     alert.alert_type = "linkUp"
     self._logger.info(
         "Posting %s alert for %s", alert.alert_type, self.get_target()
     )
     return alert
Exemple #2
0
 def _get_down_alert(self):
     alert = AlertGenerator(self.event)
     if self._verify_shadow():
         alert.alert_type = 'boxShadow'
         self._set_internal_state(Netbox.UP_SHADOW)
     else:
         alert.alert_type = 'boxDown'
     return alert
Exemple #3
0
 def _get_down_alert(self):
     alert = AlertGenerator(self.event)
     if self._verify_shadow():
         alert.alert_type = 'boxShadow'
         self._set_internal_state(Netbox.UP_SHADOW)
     else:
         alert.alert_type = 'boxDown'
     return alert
 def _get_down_alert(self):
     if self._is_netbox_currently_up():
         alert = AlertGenerator(self.event)
         alert.alert_type = 'snmpAgentDown'
         return alert
     else:
         self._logger.info("%s has gone down in the meantime, "
                           "not posting snmpAgentDown alert",
                           self.get_target())
    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()
Exemple #6
0
    def _get_down_alert(self):
        alert = AlertGenerator(self.event)
        alert.alert_type = "linkDown"

        if any((self._hold_back_alert_due_to_vlan_mismatch(),
                self._hold_back_alert_due_to_redundancy_limit())):
            self._logger.info("%s: withholding %s alert because of unmatched "
                              "criteria", self.get_target(), alert.alert_type)
            return None

        return alert
Exemple #7
0
    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()
Exemple #8
0
    def _get_down_alert(self):
        alert = AlertGenerator(self.event)
        alert.alert_type = "linkDown"

        if any((self._hold_back_alert_due_to_vlan_mismatch(),
                self._hold_back_alert_due_to_redundancy_limit())):
            self._logger.info(
                "%s: withholding %s alert because of unmatched "
                "criteria", self.get_target(), alert.alert_type)
            return None

        return alert
Exemple #9
0
    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()
Exemple #10
0
    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()
Exemple #11
0
 def _get_down_alert(self):
     alert = AlertGenerator(self.event)
     if self._is_peer_down():
         self._logger.info("%s: peer is down, not posting bgp alert",
                           self.get_target())
         return
     return alert
Exemple #12
0
    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()
Exemple #13
0
def test_should_be_able_to_render_snmpagentdown_alert_msg_template():
    details = TemplateDetails(name='snmpAgentState/snmpAgentDown-email.txt',
                              msgtype='email',
                              language='en')
    ensure_alert_templates_are_available()
    event = Mock(varmap={})
    alert = AlertGenerator(event)
    _, output = _render_template(details, alert)
    assert output
Exemple #14
0
    def _get_down_alert(self):
        self._post_event_if_aggregate_degraded()  # always verify aggregates
        alert = AlertGenerator(self.event)
        alert.alert_type = "linkDown"

        if any(
            (
                self._hold_back_alert_due_to_vlan_mismatch(),
                self._hold_back_alert_due_to_redundancy_limit(),
            )
        ):
            self._logger.info(
                "%s: withholding %s alert because of unmatched " "criteria",
                self.get_target(),
                alert.alert_type,
            )
            return None

        return alert
Exemple #15
0
 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()
Exemple #16
0
    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()
Exemple #18
0
    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()
Exemple #19
0
    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()
Exemple #20
0
    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()
Exemple #21
0
    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()
Exemple #22
0
 def _get_alert(self):
     alert = AlertGenerator(self.event)
     target = self.get_target()
     if target:
         alert['module'] = target
     return alert
Exemple #23
0
 def _get_down_alert(self):
     alert = AlertGenerator(self.event)
     alert.alert_type = 'snmpAgentDown'
     return alert
Exemple #24
0
 def _get_up_alert(self):
     alert = AlertGenerator(self.event)
     alert.alert_type = 'snmpAgentUp'
     return alert
Exemple #25
0
 def _get_up_alert(self):
     alert = AlertGenerator(self.event)
     is_shadow = self.event.netbox.up == self.event.netbox.UP_SHADOW
     alert.alert_type = "boxSunny" if is_shadow else "boxUp"
     return alert
Exemple #26
0
 def _get_up_alert(self):
     alert = AlertGenerator(self.event)
     alert.alert_type = "linkUp"
     self._logger.info("Posting %s alert for %s", alert.alert_type,
                       self.get_target())
     return alert
Exemple #27
0
 def _get_up_alert(self):
     alert = AlertGenerator(self.event)
     alert.alert_type = 'bgpEstablished'
     return alert
Exemple #28
0
 def _get_up_alert(self):
     alert = AlertGenerator(self.event)
     is_shadow = self.event.netbox.up == self.event.netbox.UP_SHADOW
     alert.alert_type = "boxSunny" if is_shadow else "boxUp"
     return alert