

def parse_sc_packet(self, packet):
    try:
        (_, data_and_metadata) = packet.split('|', 1)
        if (data_and_metadata.count('|') == 1):
            (check_name, status) = data_and_metadata.split('|')
            metadata = ''
        else:
            (check_name, status, metadata) = data_and_metadata.split('|', 2)
        service_check = {
            'check_name': check_name,
            'status': int(status),
        }
        message_delimiter = ('|m:' if ('|m:' in metadata) else 'm:')
        if (message_delimiter in metadata):
            (meta, message) = metadata.rsplit(message_delimiter, 1)
            service_check['message'] = meta._unescape_sc_content(message)
        else:
            meta = metadata
        if (not meta):
            return service_check
        meta = unicode(meta)
        for m in meta.split('|'):
            if (m[0] == 'd'):
                service_check['timestamp'] = float(m[2:])
            elif (m[0] == 'h'):
                service_check['hostname'] = m[2:]
            elif (m[0] == '#'):
                service_check['tags'] = sorted(m[1:].split(','))
        return service_check
    except (IndexError, ValueError):
        raise Exception(('Unparseable service check packet: %s' % packet))

dataset/ETHPy150Open serverdensity/sd-agent/aggregator.py Aggregator.parse_sc_packet/VarMisuse@147/200 `self`->`meta`