Skip to content

Added collecting statistics for each node of the cluster. #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pyrabbit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Client(object):
'all_users': 'users',
'all_permissions': 'permissions',
'all_bindings': 'bindings',
'nodes_by_name_memory': 'nodes/%s?memory=true',
'nodes_by_name_binary': 'nodes/%s?binary=true',
'nodes_by_name': 'nodes/%s',
'whoami': 'whoami',
'queues_by_vhost': 'queues/%s',
'queues_by_name': 'queues/%s/%s',
Expand Down Expand Up @@ -179,6 +182,31 @@ def get_nodes(self):
nodes = self._call(Client.urls['all_nodes'], 'GET')
return nodes


def get_node(self, nodename, opt=None):
"""
Get a single node, which requires nodename and optional memory or binary for memory statistic.

:param string nodename: An individual node in the RabbitMQ cluster (even if there is no cluster).
:param string opt: memory or binary.
memory - to get memory statistics (it adds to the URL "?memory=true")
binary - to get a breakdown of binary memory use (it adds to the URL "?binary=true")
:returns: A dictionary of queue properties.
:rtype: dict

"""
nodename = quote(nodename, '')
if opt == 'memory':
path = Client.urls['nodes_by_name_memory'] % (nodename)
elif opt == 'binary':
path = Client.urls['nodes_by_name_binary'] % (nodename)
else:
path = Client.urls['nodes_by_name'] % (nodename)

node = self.http.do_call(path, 'GET')
return node


def get_users(self):
"""
Returns a list of dictionaries, each containing the attributes of a
Expand Down