rbt parse

Change-Id: Icf7f51b8a486fef910272610d94a112046c3d525
This commit is contained in:
Kun Huang 2015-10-29 16:49:25 +08:00
parent 9c188cc61a
commit 84c9bd95ee
2 changed files with 17 additions and 2 deletions

View File

@ -48,3 +48,17 @@ def parse_rpc(out):
def parse_traffic(out):
return _parse_traffic(out, "Device")
def parse_rabbit(out):
"""
in:
ts, {u'_unique_id': u'xxx', u'failure': None, u'ending': True, u'result': None, u'_msg_id': u'xxx'}
out:
name: RabbitMQ
unit: None
data: [(ts, <msg body>), ...]
"""
rbt_ret = {"name": "RabbitMQ",
"unit": None,
"data": out}
return (rbt_ret, )

View File

@ -35,9 +35,10 @@ with Connection('amqp://guest:guest@localhost:5672//') as conn:
queue = Queue("trace_", task_exchange, routing_key="publish.*", channel=chan)
task_queues.append(queue)
try:
subprocess.check_call("sudo rabbitmqctl trace_on", shell=True)
# Don't need check here, if commnd failed, it would raise CalledProcessError
subprocess.check_output("sudo rabbitmqctl trace_on", shell=True)
worker = Worker(conn)
worker.run()
except KeyboardInterrupt:
subprocess.check_call("sudo rabbitmqctl trace_off", shell=True)
subprocess.check_output("sudo rabbitmqctl trace_off", shell=True)
queue.delete()