From 84c9bd95ee1a5393a4fee3aed2b82efe0e1732bb Mon Sep 17 00:00:00 2001 From: Kun Huang Date: Thu, 29 Oct 2015 16:49:25 +0800 Subject: [PATCH] rbt parse Change-Id: Icf7f51b8a486fef910272610d94a112046c3d525 --- scalpels/agents/base.py | 14 ++++++++++++++ scripts/rbt-trace.py | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scalpels/agents/base.py b/scalpels/agents/base.py index 97c6d05..8a3a5ef 100644 --- a/scalpels/agents/base.py +++ b/scalpels/agents/base.py @@ -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, ), ...] + """ + rbt_ret = {"name": "RabbitMQ", + "unit": None, + "data": out} + return (rbt_ret, ) diff --git a/scripts/rbt-trace.py b/scripts/rbt-trace.py index 6a8093d..2678e3a 100755 --- a/scripts/rbt-trace.py +++ b/scripts/rbt-trace.py @@ -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()