예제 #1
0
    def run(self):
        sender = self.destination.get_sender()

        if self.is_error:
            level = AlertLevels.ERROR
            message_context = Source.error_context(self.event.context)
        else:
            level = None    # set via options or Sender
            message_context = Source.message_context(self.event.context,
                                                     self.event.trigger_result)

        message = self.destination.get_message(message_context)
        options = self.destination.options
        if options:
            level = AlertLevels.find(options.get('level', None))

        alert = Alert(event=self.event,
                      level=level or sender.level,
                      sender=self.destination.sender,
                      message=message,
                      options=options)
        # need to save to get datetime assigned
        alert.save()
        logger.debug('Sending Alert %s via Destination %s' %
                     (alert, self.destination))
        try:
            sender.send(alert)
        except:
            logger.exception("An error occurred while sending alert %s"
                             " via Destination %s" % (alert, self.destination))
예제 #2
0
    def run(self):
        sender = self.destination.get_sender()

        if self.is_error:
            level = AlertLevels.ERROR
            message_context = Source.error_context(self.event.context)
        else:
            level = None    # set via options or Sender
            message_context = Source.message_context(self.event.context,
                                                     self.event.trigger_result)

        message = self.destination.get_message(message_context)
        options = self.destination.options
        if options:
            level = AlertLevels.find(options.get('level', None))

        alert = Alert(event=self.event,
                      level=level or sender.level,
                      sender=self.destination.sender,
                      message=message,
                      options=options)
        # need to save to get datetime assigned
        alert.save()
        logger.debug('Sending Alert %s via Destination %s' %
                     (alert, self.destination))
        try:
            sender.send(alert)
        except:
            logger.exception("An error occurred while sending alert %s"
                             " via Destination %s" % (alert, self.destination))
예제 #3
0
    def run(self):
        sender = self.destination.get_sender()
        logger.debug('XXX here - event/sender: %s/%s' % (self.event, sender))

        if self.is_error:
            level = AlertLevels.ERROR
            message_context = Source.error_context(self.event.context)
        else:
            level = None    # set via options or Sender
            message_context = Source.message_context(self.event.context,
                                                     self.event.trigger_result)

        message = self.destination.get_message(message_context)
        options = self.destination.options
        logger.debug('XXX here - message/options: %s/%s' % (message, options))
        if options:
            level = AlertLevels.find(options.get('level', None))

        try:
            alert = Alert(event=self.event,
                          level=level or sender.level,
                          sender=self.destination.sender,
                          message=message,
                          options=options)
            # need to save to get datetime assigned
            alert.save()
            logger.debug('Sending Alert %s via Destination %s' %
                         (alert, self.destination))
        except Exception as e:
            logger.error('Error saving Alert: %s' % e)

        try:
            # even if we had an error saving, may be able to still send alert
            sender.send(alert)
        except:
            logger.exception("An error occurred while sending alert %s"
                             " via Destination %s" % (alert, self.destination))
예제 #4
0
    def run(self):
        sender = self.destination.get_sender()
        logger.debug('XXX here - event/sender: %s/%s' % (self.event, sender))

        if self.is_error:
            level = AlertLevels.ERROR
            message_context = Source.error_context(self.event.context)
        else:
            level = None  # set via options or Sender
            message_context = Source.message_context(self.event.context,
                                                     self.event.trigger_result)

        message = self.destination.get_message(message_context)
        options = self.destination.options
        logger.debug('XXX here - message/options: %s/%s' % (message, options))
        if options:
            level = AlertLevels.find(options.get('level', None))

        try:
            alert = Alert(event=self.event,
                          level=level or sender.level,
                          sender=self.destination.sender,
                          message=message,
                          options=options)
            # need to save to get datetime assigned
            alert.save()
            logger.debug('Sending Alert %s via Destination %s' %
                         (alert, self.destination))
        except Exception as e:
            logger.error('Error saving Alert: %s' % e)

        try:
            # even if we had an error saving, may be able to still send alert
            sender.send(alert)
        except:
            logger.exception("An error occurred while sending alert %s"
                             " via Destination %s" % (alert, self.destination))