(self, timestamp, event_type, hostname, fields, tags=None)
return event_payload
Factory method called by the parsers
Factory method called by the parsers
Factory method called by the parsers
def create_event(self, timestamp, event_type, hostname, fields, tags=None):
        """Factory method called by the parsers"""
        # Agent6 expects a specific set of fields, so we need to place all
        # extra fields in the msg_title and let the Datadog backend separate them
        # Any remaining fields that aren't a part of the datadog-agent payload
        # specification will be dropped.
        event_payload = fields._asdict()

        msg_text = {
            'event_type': event_type,
            'event_soft_hard': event_payload.pop('event_soft_hard', None),
            'check_name': event_payload.pop('check_name', None),
            'event_state': event_payload.pop('event_state', None),
            'payload': event_payload.pop('payload', None),
            'ack_author': event_payload.pop('ack_author', None),
        }

        msg_text = json.dumps(msg_text)
        self.log.info("Nagios Event pack: %s", msg_text)

        event_payload.update(
            {
                'timestamp': timestamp,
                'event_type': event_type,
                'msg_text': msg_text,
                'source_type_name': SOURCE_TYPE_NAME,
                'tags': tags,
            }
        )

        # if host is localhost, turn that into the internal host name
        host = event_payload.get('host')
        if host == "localhost":
            event_payload["host"] = hostname
        return event_payload
def create_event ( self , timestamp , event_type , hostname , fields , tags = None ) : # Agent6 expects a specific set of fields, so we need to place all # extra fields in the msg_title and let the Datadog backend separate them # Any remaining fields that aren't a part of the datadog-agent payload # specification will be dropped. event_payload = fields . _asdict ( ) msg_text = { 'event_type' : event_type , 'event_soft_hard' : event_payload . pop ( 'event_soft_hard' , None ) , 'check_name' : event_payload . pop ( 'check_name' , None ) , 'event_state' : event_payload . pop ( 'event_state' , None ) , 'payload' : event_payload . pop ( 'payload' , None ) , 'ack_author' : event_payload . pop ( 'ack_author' , None ) , } msg_text = json . dumps ( msg_text ) self . log . info ( "Nagios Event pack: %s" , msg_text ) event_payload . update ( { 'timestamp' : timestamp , 'event_type' : event_type , 'msg_text' : msg_text , 'source_type_name' : SOURCE_TYPE_NAME , 'tags' : tags , } ) # if host is localhost, turn that into the internal host name host = event_payload . get ( 'host' ) if host == "localhost" : event_payload [ "host" ] = hostname return event_payload