Developing Python applications to monitor RabbitMQ

In this example we're going to create a Python script to monitor RabbitMQ using the JSON API that you can access from the URL http://localhost:15672/api/.

The scope of this example is to create a custom Python script, which performs some checks and sends an e-mail if it detects some errors. You can find the source code at Chapter03/Recipe07.

Getting ready

You need Python 2.7+ and the management plugin enabled (as we have seen in the Managing RabbitMQ from a browser recipe).

How to do it…

Perform the following steps to create a Python script to monitor RabbitMQ using the JSON API:

  1. Import the following libraries:
    import sys
    import urllib2,base64
    import json
    import logging
  2. Get the required RabbitMQ information ...

Get RabbitMQ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.