Skip to content

Commit

Permalink
Merge pull request #2 from sjl/master
Browse files Browse the repository at this point in the history
Two small fixes
  • Loading branch information
gleicon committed May 3, 2012
2 parents 32ec504 + f53909e commit cd9f67d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions riemann/__init__.py
Expand Up @@ -44,13 +44,13 @@ class RiemannClient():
from riemann import RiemannClient
rc = RiemannClient()
rc.send({'host':'127.0.0.1', 'service': 'www', 'state': 'down', 'metric_f': 10000})
rc.send({'host':'127.0.0.1', 'service': 'www', 'state': 'down', 'metric': 10000})
res = rc.query('host')
print res
for e in res.events: print e.host
"""
def __init__(self, host='127.0.0.1', port=5555, transport=RiemannTCPTransport):
self._fields = ['description', 'host', 'metric_f', 'service', 'state', 'tags', 'time', 'ttl']
self._fields = ['description', 'host', 'service', 'state', 'time', 'ttl']
self._host = host
self._port = port
self._transport = transport(host=host, port=port)
Expand All @@ -59,6 +59,10 @@ def send(self, edict):
ev = pb.Event()
for k in self._fields:
if edict.has_key(k): setattr(ev, k, edict[k])
if 'tags' in edict:
ev.tags.extend(edict['tags'])
if 'metric' in edict:
ev.metric_f = float(edict['metric'])
msg = pb.Msg()
msg.events.extend([ev])
b = msg.SerializeToString()
Expand Down

0 comments on commit cd9f67d

Please sign in to comment.