Permalink
Browse files

Improved the list_connections method.

  • Loading branch information...
1 parent a2827e5 commit 18e93fda72e9500e970fc4adcbc469f1d6d30b08 @clemesha-ooi clemesha-ooi committed Aug 27, 2009
Showing with 27 additions and 4 deletions.
  1. +27 −3 rabbitmqctl_service.py
  2. +0 −1 twisted/plugins/txrabbitmq.py
View
@@ -1,3 +1,4 @@
+import socket
from twisted.application import service
from twisted.internet.defer import inlineCallbacks, returnValue
from zope.interface import Interface, implements
@@ -200,7 +201,30 @@ def list_connections(self, connectioninfoitem=None):
"""list all connections"""
if connectioninfoitem is None:
infoitems = [Atom(item) for item in CONNECTION_INFO_ITEMS]
- response = {"command":"list_connections"}
- result = yield self.process.callRemote(self.nodename, "rabbit_networking", "connection_info_all", infoitems)
- print "list_connections ", result
+ result = yield self.process.callRemote(self.nodename, "rabbit_networking", "connection_info_all")#, infoitems)
+ info_all = []
+ for v in result:
+ address = ".".join([str(e) for e in v[1][1]])
+ peer_address = ".".join([str(e) for e in v[3][1]])
+ info_all.append({
+ "pid":v[0][1].nodeName.text,
+ "address":address,
+ "host":socket.gethostbyaddr(address)[0],
+ "port":str(v[2][1]),
+ "peer_address":peer_address,
+ "peer_host":socket.gethostbyaddr(peer_address)[0],
+ "peer_port":str(v[4][1]),
+ "recv_oct":str(v[5][1]),
+ "recv_cnt":str(v[6][1]),
+ "send_oct":str(v[7][1]),
+ "send_cnt":str(v[8][1]),
+ "send_pend":str(v[9][1]),
+ "state":v[10][1].text,
+ "channels":str(v[11][1]),
+ "user":v[12][1].value,
+ "vhost":v[13][1].value,
+ "timeout":str(v[14][1]),
+ "frame_max":str(v[15][1])
+ })
+ response = {"command":"list_connections", "result":info_all}
returnValue(response)
@@ -39,7 +39,6 @@ def makeService(self, options):
cookie = options['cookie']
if not cookie:
cookie = readCookie()
- print cookie
nodeName = buildNodeName(options['nodename'])
process = Process(nodeName, cookie)
rservice = RabbitMQControlService(process)

0 comments on commit 18e93fd

Please sign in to comment.