Code Monkey home page Code Monkey logo

bernhard's People

Contributors

b20n avatar bmhatfield avatar brutasse avatar michaeldoyle avatar npezolano avatar nukemberg avatar peterscott avatar satterly avatar tsionyx avatar zackdever avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bernhard's Issues

Error on Windows: AttributeError: 'module' object has no attribute 'MSG_WAITALL'

This error occurs when trying to send from a windows client to a Linux Riemann server.

C:\python\site-packages\bernhard__init__.pyc in write(self, message)
50 rxlen = struct.unpack('!I', self.sock.recv(4))[0]
51 # Rx entire response
---> 52 response = self.sock.recv(rxlen, socket.MSG_WAITALL)
53 return response
54 except (socket.error, struct.error) as e:

AttributeError: 'module' object has no attribute 'MSG_WAITALL'

This is a known issue described here with a potential fix:
https://bugs.launchpad.net/myconnpy/+bug/437972
dtmilano/AndroidViewClient#90

Not getting exception when receiving a socket timeout

I use a script to monitor riemann and report when things are messed up. I have the following code and cl == bernhard.Client():

def send_event(cl):
        log.debug('Sending event')
        try:
                cl.send({'host': 'localhost',
                        'service':'Riemann Monitor',
                        'state':'ok',
                        'ttl':60})
                log.debug('sent')
        except Exception as e:
                log.error(e)
                pd_trigger('Cannot send event')

I had an issue where riemann was hung up or something which is fine because the code above should catch an exception but the issue was a socket timeout and somehow bernhard didn't throw an exception?

Exception sending event to Riemann over TCP socket: timed out
Traceback (most recent call last):
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/bernhard/__init__.py", line 79, in write
response = self.read_exactly(self.sock, 4)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/bernhard/__init__.py", line 64, in read_exactly
data = sock.recv(size - len(buffer))
socket.timeout: timed out

I have yet to take a look at the bernhard code but will probably tomorrow, sometime next week, or whenever I get around to it. It would be nice if you could help me fix this issue though and get bernhard's client to throw an exception for socket timeouts. Thanks much.

bernhard incompatible with protobuf 4.21.1

Versions

  • Python 3.9.12
  • protobuf - 3.2.0
  • bernhard - 4.21.1

Steps to reproduce

  • Install lastest version of protobuf, pip install protobuf==4.21.1
  • Install bernhard, pip install bernhard
  • Run an inline command to import bernhard, python -c "import bernhard", throws the error,
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/bernhard/__init__.py", line 20, in <module>
    from . import pb
  File "/usr/local/lib/python3.9/site-packages/bernhard/pb.py", line 13, in <module>
    DESCRIPTOR = _descriptor.FileDescriptor(
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 1028, in __new__
    return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: expected bytes, str found

Template copied from #29 ๐Ÿ˜„

unicode error in python2.6

In python2.6, adding custom fields with "attributes": {} will cause error if value in the dict is not ascii because str(value[key]) is used. We can use unicode but in python3.x this will cause error.

Tags don't work

The protocol buffer library doesn't let you set a list attribute with = -- you need to use extend(). Here's how I fixed it in the pyriemann client: sjl/pyriemann@e2e2227

Allow the Client to be created when Riemann is down

The pyriemann client lets you create a Client regardless of whether the Riemann server it's pointing at is alive or not. You only get an error when you actually try to send() something, and then if the server comes up later it'll start working.

Bernhard currently throws an error when you try to create a Client while Riemann is down.

pyriemann's behavior is really handy for us, because intermittent problems with Riemann during our app's startup don't prevent stats from being sent once it's back up again.

Numeric custom attributes not available

This is more of a feature request than an issue.
From what I see all custom attributes are cast to string, while others fields (TTL) are defined as int64.
Any chance to allow sending numeric fields to Riemann?

Python 3 and protobuf

Currently, the protobuf package on PyPI doesn't work on Python 3. It will install, but try using it:

# python
Python 3.5.1 (default, Dec 15 2015, 14:52:59)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.protobuf import reflection
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ttvrtkovic/pg/.venv/lib/python3.5/site-packages/google/protobuf/reflection.py", line 68, in <module>
    from google.protobuf.internal import python_message
  File "/Users/ttvrtkovic/pg/.venv/lib/python3.5/site-packages/google/protobuf/internal/python_message.py", line 848
    except struct.error, e:
                       ^
SyntaxError: invalid syntax

Cool, huh? So for the time being, bernhard is Python 2 only I guess.

There's a Python 3 fork called 'python3_protobuf', used by for example the Riak client (https://github.com/basho/riak-python-client/blob/master/setup.py). Do you think bernhard could work with this version? If so, I'd suggest conditionally depending on protobuf on Python 2 and python3_protobuf on Python 3.

(But I wouldn't do it like in the linked Riak setup.py, but rather like this: https://github.com/pytest-dev/pytest-asyncio/blob/master/setup.py#L47

bernhard incompatible with protobuf 3.2.0

Versions

  • Python 2.7.6
  • protobuf - 3.2.0
  • bernhard - 0.2.4

Steps to reproduce

  • Install lastest version of protobuf pip install protobuf==3.2.0
  • Install bernhard pip install bernhard
  • Run an inline command to import bernhard python -c "import bernhard"

Error that appears

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/bernhard/__init__.py", line 11, in <module>
    from . import pb
  File "/usr/local/lib/python2.7/dist-packages/bernhard/pb.py", line 34, in <module>
    options=None),
  File "/usr/local/lib/python2.7/dist-packages/google/protobuf/descriptor.py", line 494, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors should not be created directly, but only retrieved from their parent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.