bernhard-0.2.6/0000755000076500000240000000000013217114575014377 5ustar banjiewenstaff00000000000000bernhard-0.2.6/.gitignore0000644000076500000240000000004612454371647016376 0ustar banjiewenstaff00000000000000*.pyc bernhard.egg-info/ dist/ build/ bernhard-0.2.6/bernhard/0000755000076500000240000000000013217114575016164 5ustar banjiewenstaff00000000000000bernhard-0.2.6/bernhard/__init__.py0000644000076500000240000002062713217114177020302 0ustar banjiewenstaff00000000000000# -*- coding: utf-8 - import logging log = logging.getLogger(__name__) import pkg_resources import socket import ssl import struct import sys try: PROTOBUF_VERSION = pkg_resources.get_distribution('protobuf').version except pkg_resources.DistributionNotFound: PROTOBUF_VERSION = 'unknown' if PROTOBUF_VERSION.startswith('3'): from . import proto_pb2 as pb else: from . import pb string_type = str if sys.version_info[1] < 3: string_type = basestring class TransportError(Exception): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg class TCPTransport(object): def __init__(self, host, port): for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: log.debug("Creating socket with %s %s %s", af, socktype, proto) self.sock = socket.socket(af, socktype, proto) self.sock.settimeout(15.0) except socket.error as e: log.exception("Exception creating TCP socket: %s", e) self.sock = None continue try: self.sock.connect(sa) except socket.error as e: log.exception("Exception connecting to TCP socket: %s", e) self.sock.close() self.sock = None continue break if self.sock is None: raise TransportError("Could not open TCP socket.") def close(self): self.sock.close() def read_exactly(self, sock, size): buffer = bytes() # empty bytes sequence for Python 2.6+ while len(buffer) < size: data = sock.recv(size - len(buffer)) if not data: log.debug("Expected to read %s bytes, but read %s bytes", size, len(buffer)) break buffer += data return buffer def write(self, message): try: # Tx length header and message log.debug("Sending event to Riemann") self.sock.sendall(struct.pack('!I', len(message)) + message) # Rx length header log.debug("Reading Riemann Response Length Header") response = self.read_exactly(self.sock, 4) rxlen = struct.unpack('!I', response)[0] log.debug("Header Length Is: %d", rxlen) # Rx entire response log.debug("Reading Riemann Response") response = self.read_exactly(self.sock, rxlen) return response except (socket.error, struct.error) as e: log.exception("Exception sending event to Riemann over TCP socket: %s", e) raise TransportError(str(e)) class SSLTransport(TCPTransport): def __init__(self, host, port, keyfile=None, certfile=None, ca_certs=None): log.debug("Using SSL Transport") TCPTransport.__init__(self, host, port) self.sock = ssl.wrap_socket(self.sock, keyfile=keyfile, certfile=certfile, cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_TLSv1, ca_certs=ca_certs) class UDPTransport(object): def __init__(self, host, port): log.debug("Using UDP Transport") self.host = None self.port = None for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_DGRAM): af, socktype, proto, canonname, sa = res try: self.sock = socket.socket(af, socktype, proto) self.host = sa[0] self.port = sa[1] except socket.error as e: log.exception("Exception opening socket: %s", e) self.sock = None continue break if self.sock is None: raise TransportError("Could not open socket.") def close(self): self.sock.close() def write(self, message): try: self.sock.sendto(message, (self.host, self.port)) except socket.error as e: log.exception("Exception writing to socket: %s", e) raise TransportError(str(e)) class Event(object): def __init__(self, event=None, params=None): if event: self.event = event elif params: self.event = pb.Event() for key, value in params.items(): setattr(self, key, value) else: self.event = pb.Event() def __getattr__(self, name): if name == 'metric': name = 'metric_f' if name in set(f.name for f in pb.Event.DESCRIPTOR.fields): return getattr(self.event, name) def __setattr__(self, name, value): if name == 'metric': name = 'metric_f' if name == 'tags': self.event.tags.extend(value) elif name == 'attributes': if type(value) == dict: for key, val in value.items(): a = self.event.attributes.add() a.key = key if isinstance(val, bytes): val = val.decode('utf-8') elif not isinstance(val, string_type): val = string_type(val) a.value = string_type(val) else: raise TypeError("'attributes' parameter must be type 'dict'") elif name in set(f.name for f in pb.Event.DESCRIPTOR.fields): setattr(self.event, name, value) else: object.__setattr__(self, name, value) def __str__(self): return str(self.event) class Message(object): def __init__(self, message=None, events=None, raw=None, query=None): if raw: self.message = pb.Msg().FromString(raw) elif message: self.message = message elif events: self.message = pb.Msg() self.message.events.extend([e.event for e in events]) elif query: self.message = pb.Msg() self.message.query.string = str(query) else: self.message = pb.Msg() def __getattr__(self, name): if name in set(f.name for f in pb.Msg.DESCRIPTOR.fields): return getattr(self.message, name) def __setattr__(self, name, value): if name in set(f.name for f in pb.Msg.DESCRIPTOR.fields): setattr(self.message, name, value) else: object.__setattr__(self, name, value) # Special-case the `events` field so we get boxed objects @property def events(self): return [Event(event=e) for e in self.message.events] @property def raw(self): return self.message.SerializeToString() class Client(object): def __init__(self, host='127.0.0.1', port=5555, transport=TCPTransport): self.host = host self.port = port self.transport = transport self.connection = None def connect(self): self.connection = self.transport(self.host, self.port) def disconnect(self): try: self.connection.close() except Exception as e: log.exception("Exception disconnecting client: %s", e) pass self.connection = None def transmit(self, message): for i in range(2): if not self.connection: self.connect() try: raw = self.connection.write(message.raw) return Message(raw=raw) except TransportError: self.disconnect() return Message() def send(self, *events): message = Message(events=[Event(params=event) for event in events]) response = self.transmit(message) return response.ok def query(self, q): message = Message(query=q) response = self.transmit(message) return response.events class SSLClient(Client): def __init__(self, host='127.0.0.1', port=5554, keyfile=None, certfile=None, ca_certs=None): Client.__init__(self, host=host, port=port, transport=SSLTransport) self.keyfile = keyfile self.certfile = certfile self.ca_certs = ca_certs def connect(self): self.connection = self.transport(self.host, self.port, self.keyfile, self.certfile, self.ca_certs) bernhard-0.2.6/bernhard/pb.py0000644000076500000240000003273012454371647017153 0ustar banjiewenstaff00000000000000# Generated by the protocol buffer compiler. DO NOT EDIT! # source: proto.proto from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) DESCRIPTOR = _descriptor.FileDescriptor( name='proto.proto', package='', serialized_pb='\n\x0bproto.proto\"\x81\x01\n\x05State\x12\x0c\n\x04time\x18\x01 \x01(\x03\x12\r\n\x05state\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x0c\n\x04host\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t\x12\x0c\n\x04once\x18\x06 \x01(\x08\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0b\n\x03ttl\x18\x08 \x01(\x02\"\xce\x01\n\x05\x45vent\x12\x0c\n\x04time\x18\x01 \x01(\x03\x12\r\n\x05state\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x0c\n\x04host\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0b\n\x03ttl\x18\x08 \x01(\x02\x12\x1e\n\nattributes\x18\t \x03(\x0b\x32\n.Attribute\x12\x15\n\rmetric_sint64\x18\r \x01(\x12\x12\x10\n\x08metric_d\x18\x0e \x01(\x01\x12\x10\n\x08metric_f\x18\x0f \x01(\x02\"\x17\n\x05Query\x12\x0e\n\x06string\x18\x01 \x01(\t\"g\n\x03Msg\x12\n\n\x02ok\x18\x02 \x01(\x08\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x16\n\x06states\x18\x04 \x03(\x0b\x32\x06.State\x12\x15\n\x05query\x18\x05 \x01(\x0b\x32\x06.Query\x12\x16\n\x06\x65vents\x18\x06 \x03(\x0b\x32\x06.Event\"\'\n\tAttribute\x12\x0b\n\x03key\x18\x01 \x02(\t\x12\r\n\x05value\x18\x02 \x01(\tB\x1a\n\x11\x63om.aphyr.riemannB\x05Proto') _STATE = _descriptor.Descriptor( name='State', full_name='State', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='time', full_name='State.time', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='state', full_name='State.state', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='service', full_name='State.service', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='host', full_name='State.host', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='description', full_name='State.description', index=4, number=5, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='once', full_name='State.once', index=5, number=6, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='tags', full_name='State.tags', index=6, number=7, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='ttl', full_name='State.ttl', index=7, number=8, type=2, cpp_type=6, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=16, serialized_end=145, ) _EVENT = _descriptor.Descriptor( name='Event', full_name='Event', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='time', full_name='Event.time', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='state', full_name='Event.state', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='service', full_name='Event.service', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='host', full_name='Event.host', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='description', full_name='Event.description', index=4, number=5, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='tags', full_name='Event.tags', index=5, number=7, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='ttl', full_name='Event.ttl', index=6, number=8, type=2, cpp_type=6, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='attributes', full_name='Event.attributes', index=7, number=9, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='metric_sint64', full_name='Event.metric_sint64', index=8, number=13, type=18, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='metric_d', full_name='Event.metric_d', index=9, number=14, type=1, cpp_type=5, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='metric_f', full_name='Event.metric_f', index=10, number=15, type=2, cpp_type=6, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=148, serialized_end=354, ) _QUERY = _descriptor.Descriptor( name='Query', full_name='Query', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='string', full_name='Query.string', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=356, serialized_end=379, ) _MSG = _descriptor.Descriptor( name='Msg', full_name='Msg', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='ok', full_name='Msg.ok', index=0, number=2, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='error', full_name='Msg.error', index=1, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='states', full_name='Msg.states', index=2, number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='query', full_name='Msg.query', index=3, number=5, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='events', full_name='Msg.events', index=4, number=6, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=381, serialized_end=484, ) _ATTRIBUTE = _descriptor.Descriptor( name='Attribute', full_name='Attribute', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='key', full_name='Attribute.key', index=0, number=1, type=9, cpp_type=9, label=2, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='value', full_name='Attribute.value', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=u"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], serialized_start=486, serialized_end=525, ) _EVENT.fields_by_name['attributes'].message_type = _ATTRIBUTE _MSG.fields_by_name['states'].message_type = _STATE _MSG.fields_by_name['query'].message_type = _QUERY _MSG.fields_by_name['events'].message_type = _EVENT DESCRIPTOR.message_types_by_name['State'] = _STATE DESCRIPTOR.message_types_by_name['Event'] = _EVENT DESCRIPTOR.message_types_by_name['Query'] = _QUERY DESCRIPTOR.message_types_by_name['Msg'] = _MSG DESCRIPTOR.message_types_by_name['Attribute'] = _ATTRIBUTE def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. class metaclass(meta): def __new__(cls, name, this_bases, d): return meta(name, bases, d) return type.__new__(metaclass, 'temporary_class', (), {}) class State(with_metaclass(_reflection.GeneratedProtocolMessageType, _message.Message)): DESCRIPTOR = _STATE # @@protoc_insertion_point(class_scope:State) class Event(with_metaclass(_reflection.GeneratedProtocolMessageType, _message.Message)): DESCRIPTOR = _EVENT # @@protoc_insertion_point(class_scope:Event) class Query(with_metaclass(_reflection.GeneratedProtocolMessageType, _message.Message)): DESCRIPTOR = _QUERY # @@protoc_insertion_point(class_scope:Query) class Msg(with_metaclass(_reflection.GeneratedProtocolMessageType, _message.Message)): DESCRIPTOR = _MSG # @@protoc_insertion_point(class_scope:Msg) class Attribute(with_metaclass(_reflection.GeneratedProtocolMessageType, _message.Message)): DESCRIPTOR = _ATTRIBUTE # @@protoc_insertion_point(class_scope:Attribute) DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), '\n\021com.aphyr.riemannB\005Proto') # @@protoc_insertion_point(module_scope) bernhard-0.2.6/bernhard/proto_pb2.py0000644000076500000240000003436013076000424020440 0ustar banjiewenstaff00000000000000# Generated by the protocol buffer compiler. DO NOT EDIT! # source: proto.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() DESCRIPTOR = _descriptor.FileDescriptor( name='proto.proto', package='', syntax='proto2', serialized_pb=_b('\n\x0bproto.proto\"\x81\x01\n\x05State\x12\x0c\n\x04time\x18\x01 \x01(\x03\x12\r\n\x05state\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x0c\n\x04host\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t\x12\x0c\n\x04once\x18\x06 \x01(\x08\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0b\n\x03ttl\x18\x08 \x01(\x02\"\xce\x01\n\x05\x45vent\x12\x0c\n\x04time\x18\x01 \x01(\x03\x12\r\n\x05state\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x0c\n\x04host\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x0b\n\x03ttl\x18\x08 \x01(\x02\x12\x1e\n\nattributes\x18\t \x03(\x0b\x32\n.Attribute\x12\x15\n\rmetric_sint64\x18\r \x01(\x12\x12\x10\n\x08metric_d\x18\x0e \x01(\x01\x12\x10\n\x08metric_f\x18\x0f \x01(\x02\"\x17\n\x05Query\x12\x0e\n\x06string\x18\x01 \x01(\t\"g\n\x03Msg\x12\n\n\x02ok\x18\x02 \x01(\x08\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x16\n\x06states\x18\x04 \x03(\x0b\x32\x06.State\x12\x15\n\x05query\x18\x05 \x01(\x0b\x32\x06.Query\x12\x16\n\x06\x65vents\x18\x06 \x03(\x0b\x32\x06.Event\"\'\n\tAttribute\x12\x0b\n\x03key\x18\x01 \x02(\t\x12\r\n\x05value\x18\x02 \x01(\tB\x1a\n\x11\x63om.aphyr.riemannB\x05Proto') ) _sym_db.RegisterFileDescriptor(DESCRIPTOR) _STATE = _descriptor.Descriptor( name='State', full_name='State', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='time', full_name='State.time', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='state', full_name='State.state', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='service', full_name='State.service', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='host', full_name='State.host', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='description', full_name='State.description', index=4, number=5, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='once', full_name='State.once', index=5, number=6, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='tags', full_name='State.tags', index=6, number=7, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='ttl', full_name='State.ttl', index=7, number=8, type=2, cpp_type=6, label=1, has_default_value=False, default_value=float(0), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto2', extension_ranges=[], oneofs=[ ], serialized_start=16, serialized_end=145, ) _EVENT = _descriptor.Descriptor( name='Event', full_name='Event', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='time', full_name='Event.time', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='state', full_name='Event.state', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='service', full_name='Event.service', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='host', full_name='Event.host', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='description', full_name='Event.description', index=4, number=5, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='tags', full_name='Event.tags', index=5, number=7, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='ttl', full_name='Event.ttl', index=6, number=8, type=2, cpp_type=6, label=1, has_default_value=False, default_value=float(0), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='attributes', full_name='Event.attributes', index=7, number=9, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='metric_sint64', full_name='Event.metric_sint64', index=8, number=13, type=18, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='metric_d', full_name='Event.metric_d', index=9, number=14, type=1, cpp_type=5, label=1, has_default_value=False, default_value=float(0), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='metric_f', full_name='Event.metric_f', index=10, number=15, type=2, cpp_type=6, label=1, has_default_value=False, default_value=float(0), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto2', extension_ranges=[], oneofs=[ ], serialized_start=148, serialized_end=354, ) _QUERY = _descriptor.Descriptor( name='Query', full_name='Query', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='string', full_name='Query.string', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto2', extension_ranges=[], oneofs=[ ], serialized_start=356, serialized_end=379, ) _MSG = _descriptor.Descriptor( name='Msg', full_name='Msg', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='ok', full_name='Msg.ok', index=0, number=2, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='error', full_name='Msg.error', index=1, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='states', full_name='Msg.states', index=2, number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='query', full_name='Msg.query', index=3, number=5, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='events', full_name='Msg.events', index=4, number=6, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto2', extension_ranges=[], oneofs=[ ], serialized_start=381, serialized_end=484, ) _ATTRIBUTE = _descriptor.Descriptor( name='Attribute', full_name='Attribute', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='key', full_name='Attribute.key', index=0, number=1, type=9, cpp_type=9, label=2, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='value', full_name='Attribute.value', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto2', extension_ranges=[], oneofs=[ ], serialized_start=486, serialized_end=525, ) _EVENT.fields_by_name['attributes'].message_type = _ATTRIBUTE _MSG.fields_by_name['states'].message_type = _STATE _MSG.fields_by_name['query'].message_type = _QUERY _MSG.fields_by_name['events'].message_type = _EVENT DESCRIPTOR.message_types_by_name['State'] = _STATE DESCRIPTOR.message_types_by_name['Event'] = _EVENT DESCRIPTOR.message_types_by_name['Query'] = _QUERY DESCRIPTOR.message_types_by_name['Msg'] = _MSG DESCRIPTOR.message_types_by_name['Attribute'] = _ATTRIBUTE State = _reflection.GeneratedProtocolMessageType('State', (_message.Message,), dict( DESCRIPTOR = _STATE, __module__ = 'proto_pb2' # @@protoc_insertion_point(class_scope:State) )) _sym_db.RegisterMessage(State) Event = _reflection.GeneratedProtocolMessageType('Event', (_message.Message,), dict( DESCRIPTOR = _EVENT, __module__ = 'proto_pb2' # @@protoc_insertion_point(class_scope:Event) )) _sym_db.RegisterMessage(Event) Query = _reflection.GeneratedProtocolMessageType('Query', (_message.Message,), dict( DESCRIPTOR = _QUERY, __module__ = 'proto_pb2' # @@protoc_insertion_point(class_scope:Query) )) _sym_db.RegisterMessage(Query) Msg = _reflection.GeneratedProtocolMessageType('Msg', (_message.Message,), dict( DESCRIPTOR = _MSG, __module__ = 'proto_pb2' # @@protoc_insertion_point(class_scope:Msg) )) _sym_db.RegisterMessage(Msg) Attribute = _reflection.GeneratedProtocolMessageType('Attribute', (_message.Message,), dict( DESCRIPTOR = _ATTRIBUTE, __module__ = 'proto_pb2' # @@protoc_insertion_point(class_scope:Attribute) )) _sym_db.RegisterMessage(Attribute) DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\021com.aphyr.riemannB\005Proto')) try: # THESE ELEMENTS WILL BE DEPRECATED. # Please use the generated *_pb2_grpc.py files instead. import grpc from grpc.framework.common import cardinality from grpc.framework.interfaces.face import utilities as face_utilities from grpc.beta import implementations as beta_implementations from grpc.beta import interfaces as beta_interfaces except ImportError: pass # @@protoc_insertion_point(module_scope) bernhard-0.2.6/bernhard.egg-info/0000755000076500000240000000000013217114575017656 5ustar banjiewenstaff00000000000000bernhard-0.2.6/bernhard.egg-info/dependency_links.txt0000644000076500000240000000000113217114575023724 0ustar banjiewenstaff00000000000000 bernhard-0.2.6/bernhard.egg-info/not-zip-safe0000644000076500000240000000000112454371752022110 0ustar banjiewenstaff00000000000000 bernhard-0.2.6/bernhard.egg-info/PKG-INFO0000644000076500000240000000370013217114575020753 0ustar banjiewenstaff00000000000000Metadata-Version: 1.1 Name: bernhard Version: 0.2.6 Summary: Python client for Riemann Home-page: http://github.com/banjiewen/bernhard.git Author: Benjamin Anderspn Author-email: b@banjiewen.net License: ASF2.0 Description-Content-Type: UNKNOWN Description: # Bernhard A simple Python client for [Riemann](http://github.com/aphyr/riemann). Usage: ```python import bernhard c = bernhard.Client() c.send({'host': 'myhost.foobar.com', 'service': 'myservice', 'metric': 12}) q = c.query('true') ``` Bernhard supports custom attributes with the syntax: ```python import bernhard c = bernhard.Client() c.send({'host': 'awesome.host.com', 'attributes': {'sky': 'sunny', 'sea': 'agitated'}}) ``` Querying the index is as easy as: ```python import bernhard c = bernhard.Client() q = c.query('true') for e in q: print "Host:", e.host, "State:", e.state ``` ## Installing ```bash pip install bernhard ``` You may encounter issues with the `protobuf` dependency; if so, just run `pip install protobuf` manually, then `pip install bernhard`. Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Environment :: Other Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: POSIX Classifier: Operating System :: Unix Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Internet :: Log Analysis Classifier: Topic :: Utilities Classifier: Topic :: System :: Networking :: Monitoring bernhard-0.2.6/bernhard.egg-info/requires.txt0000644000076500000240000000001613217114575022253 0ustar banjiewenstaff00000000000000protobuf>=2.4 bernhard-0.2.6/bernhard.egg-info/SOURCES.txt0000644000076500000240000000045113217114575021542 0ustar banjiewenstaff00000000000000.gitignore LICENSE MANIFEST.in README.md setup.py bernhard/__init__.py bernhard/pb.py bernhard/proto_pb2.py bernhard.egg-info/PKG-INFO bernhard.egg-info/SOURCES.txt bernhard.egg-info/dependency_links.txt bernhard.egg-info/not-zip-safe bernhard.egg-info/requires.txt bernhard.egg-info/top_level.txtbernhard-0.2.6/bernhard.egg-info/top_level.txt0000644000076500000240000000001113217114575022400 0ustar banjiewenstaff00000000000000bernhard bernhard-0.2.6/LICENSE0000644000076500000240000002566512454371647015431 0ustar banjiewenstaff00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. bernhard-0.2.6/MANIFEST.in0000644000076500000240000000006512454371647016145 0ustar banjiewenstaff00000000000000include .gitignore include LICENSE include README.md bernhard-0.2.6/PKG-INFO0000644000076500000240000000370013217114575015474 0ustar banjiewenstaff00000000000000Metadata-Version: 1.1 Name: bernhard Version: 0.2.6 Summary: Python client for Riemann Home-page: http://github.com/banjiewen/bernhard.git Author: Benjamin Anderspn Author-email: b@banjiewen.net License: ASF2.0 Description-Content-Type: UNKNOWN Description: # Bernhard A simple Python client for [Riemann](http://github.com/aphyr/riemann). Usage: ```python import bernhard c = bernhard.Client() c.send({'host': 'myhost.foobar.com', 'service': 'myservice', 'metric': 12}) q = c.query('true') ``` Bernhard supports custom attributes with the syntax: ```python import bernhard c = bernhard.Client() c.send({'host': 'awesome.host.com', 'attributes': {'sky': 'sunny', 'sea': 'agitated'}}) ``` Querying the index is as easy as: ```python import bernhard c = bernhard.Client() q = c.query('true') for e in q: print "Host:", e.host, "State:", e.state ``` ## Installing ```bash pip install bernhard ``` You may encounter issues with the `protobuf` dependency; if so, just run `pip install protobuf` manually, then `pip install bernhard`. Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Environment :: Other Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: POSIX Classifier: Operating System :: Unix Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Internet :: Log Analysis Classifier: Topic :: Utilities Classifier: Topic :: System :: Networking :: Monitoring bernhard-0.2.6/README.md0000644000076500000240000000142412544371330015653 0ustar banjiewenstaff00000000000000# Bernhard A simple Python client for [Riemann](http://github.com/aphyr/riemann). Usage: ```python import bernhard c = bernhard.Client() c.send({'host': 'myhost.foobar.com', 'service': 'myservice', 'metric': 12}) q = c.query('true') ``` Bernhard supports custom attributes with the syntax: ```python import bernhard c = bernhard.Client() c.send({'host': 'awesome.host.com', 'attributes': {'sky': 'sunny', 'sea': 'agitated'}}) ``` Querying the index is as easy as: ```python import bernhard c = bernhard.Client() q = c.query('true') for e in q: print "Host:", e.host, "State:", e.state ``` ## Installing ```bash pip install bernhard ``` You may encounter issues with the `protobuf` dependency; if so, just run `pip install protobuf` manually, then `pip install bernhard`. bernhard-0.2.6/setup.cfg0000644000076500000240000000004613217114575016220 0ustar banjiewenstaff00000000000000[egg_info] tag_build = tag_date = 0 bernhard-0.2.6/setup.py0000644000076500000240000000233513217114244016105 0ustar banjiewenstaff00000000000000# -*- coding: utf-8 - import codecs import io import os from setuptools import setup with io.open(os.path.join(os.path.dirname(__file__), 'README.md'), encoding='utf-8') as f: long_description = f.read() setup( name = 'bernhard', version = '0.2.6', description = 'Python client for Riemann', long_description = long_description, author = 'Benjamin Anderspn', author_email = 'b@banjiewen.net', license = 'ASF2.0', url = 'http://github.com/banjiewen/bernhard.git', classifiers = [ 'Development Status :: 4 - Beta', 'Environment :: Other Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Operating System :: MacOS :: MacOS X', 'Operating System :: POSIX', 'Operating System :: Unix', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Internet :: Log Analysis', 'Topic :: Utilities', 'Topic :: System :: Networking :: Monitoring' ], zip_safe = False, packages = ['bernhard'], include_package_data = True, install_requires=['protobuf >= 2.4'] )