Created
May 28, 2021 05:12
-
-
Save uncelvel/b6384fb32628c244bcdd7a48f16a36e8 to your computer and use it in GitHub Desktop.
check_rabbitmq.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment