bkjones / pyrabbit

A Python module to communicate w/ the RabbitMQ HTTP Management API
http://pyrabbit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
97 stars 86 forks source link

add get_node (node details) #48

Closed samosvat closed 8 years ago

samosvat commented 8 years ago

It will collect statistics for each node of the cluster (or single node, if there is no cluster). And so the same memory usage statistics (memory|binary)

add to api.py:

urls = {
            'nodes_by_name_memory': 'nodes/%s?memory=true',
            'nodes_by_name_binary': 'nodes/%s?binary=true',
            'nodes_by_name': 'nodes/%s',
#########################################

    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)

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

Thank you! Sorry for my english