Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify rabbitmq credentials are valid

I'd like to write a simple smoke test that runs after deployment to verify that the RabbitMQ credentials are valid. What's the simplest way to check that rabbitmq username/password/vhost are valid?

Edit: Preferably, check using a bash script. Alternatively, using a Python script.

like image 383
Lorin Hochstein Avatar asked Jun 17 '13 13:06

Lorin Hochstein


People also ask

How do I check my RabbitMQ credentials?

Open the RabbitMQ management console, http://localhost:15672 . Login as a guest. Enter guest as the Username and Password. Note: The default user “guest” is an administrative user and its login credentials are published on the official RabbitMQ web site.

How do I check my RabbitMQ status?

For Linux/Unix/Mac: 0 you can use the RabbitMQ command line tool. You can also use the rabbitmq-diagnostics to check the server_version. It's a useful tool for diagnostics, health checks and monitoring. The command assumes that accessing your console requires sudo rights.

Where does RabbitMQ store credentials?

RabbitMQ supports multiple authentication mechanisms. Some of them use username/password pairs. These credential pairs are then handed over to authentication backends that perform authentication. One of the backends, known as internal or built-in, uses internal RabbitMQ data store to store user credentials.

What is the default RabbitMQ password?

Procedure: Log in to the RabbitMQ web-based management interface as admin admin using the default password of changeme.


2 Answers

As you haven't provided any details about language, etc.:

You could simply issue a HTTP GET request to the management api.

$ curl -i -u guest:guest http://localhost:15672/api/whoami 

See RabbitMQ Management HTTP API

like image 95
ccellar Avatar answered Sep 28 '22 08:09

ccellar


Here's a way to check using Python:

#!/usr/bin/env python import socket from kombu import Connection host = "localhost" port = 5672 user = "guest" password = "guest" vhost = "/" url = 'amqp://{0}:{1}@{2}:{3}/{4}'.format(user, password, host, port, vhost) with Connection(url) as c:     try:         c.connect()     except socket.error:         raise ValueError("Received socket.error, "                          "rabbitmq server probably isn't running")     except IOError:         raise ValueError("Received IOError, probably bad credentials")     else:         print "Credentials are valid" 
like image 33
Lorin Hochstein Avatar answered Sep 28 '22 06:09

Lorin Hochstein