https://github.com/rob-blackbourn/jetblack-rabbitmqmon
A Python3 asyncio API for the RabbitMQ management plugin
https://github.com/rob-blackbourn/jetblack-rabbitmqmon
aiohttp aiohttp-client asyncio bareasgi bareclient python python3 rabbitmq
Last synced: about 2 months ago
JSON representation
A Python3 asyncio API for the RabbitMQ management plugin
- Host: GitHub
- URL: https://github.com/rob-blackbourn/jetblack-rabbitmqmon
- Owner: rob-blackbourn
- Created: 2020-04-18T09:30:50.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-24T08:51:05.000Z (almost 5 years ago)
- Last Synced: 2025-03-08T10:02:54.754Z (2 months ago)
- Topics: aiohttp, aiohttp-client, asyncio, bareasgi, bareclient, python, python3, rabbitmq
- Language: Python
- Size: 64.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gascode-rabbitmqmon
This is an asyncio RabbitMQ monitor API for Python3.7+.
It wraps the RabbitMQ management plugin REST api. This allows retrieving
metrics and peeking into the queues.## Status
This is work in progress, but is functional.
## Installation
This can be installed with pip.
Multiple clients a supported and one *must* be selected. Choose one of:
* [aiohttp](https://github.com/aio-libs/aiohttp)
* [bareclient](https://github.com/rob-blackbourn/bareClient)```bash
pip install gascode-rabbitmqmon[bareclient]
```Or alternatively:
```bash
pip install gascode-rabbitmqmon[aiohttp]
```## Usage
The following gets an overview using the bareclient.
```python
import asyncio
from gascode_rabbitmqmon.monitor import Monitor
from gascode_rabbitmqmon.clients.bareclient_requester import BareRequesterasync def main_async():
mon = Monitor(
BareRequester(
'http://mq.example.com:15672',
'admin',
'admins password'
)
)overview = await mon.overview()
print(overview)if __name__ == '__main__':
asyncio.run(main_async())
```The follow explores a vhost using the aiohttp client.
```python
import asyncio
from gascode_rabbitmqmon.monitor import Monitor
from gascode_rabbitmqmon.clients.aiohttp_requester import AioHttpRequesterasync def main_async():
mon = Monitor(
AioHttpRequester(
'http://mq.example.com:15672',
'admin',
'admins password'
)
)vhosts = await mon.vhosts()
for vhost in vhosts.values(): # vhost is a dict
exchanges = await vhost.exchanges()
for exchange in exchanges.values(): # exchanges is a dict
print(exchange)
# Objects can be refreshed to gather new metrics.
await exchange.refresh()
print(exchange)
bindings = await exchange.bindings()
for binding in bindings:
print(binding)if __name__ == '__main__':
asyncio.run(main_async())
```The following gets some messages from an exchange using the bareclient.
```python
import asyncio
from gascode_rabbitmqmon.monitor import Monitor
from gascode_rabbitmqmon.clients.bareclient_requester import BareRequesterasync def main_async():
mon = Monitor(
BareRequester(
'http://mq.example.com:15672',
'admin',
'admins password'
)
)vhosts = await mon.vhosts()
vhost = vhosts['/some-vhost']
queues = await vhost.queues()
queue = queues['some.queue']
messages = await queue.get_messages()
print(messages)if __name__ == '__main__':
asyncio.run(main_async())
```