check-rabbitmq-queue: Put user check before rabbitmqctl call.

This commit is contained in:
Mateusz Mandera 2020-03-20 17:59:08 +01:00 committed by Tim Abbott
parent 5da2f80140
commit ea93810d9a
1 changed files with 3 additions and 3 deletions

View File

@ -32,15 +32,15 @@ states = {
}
pattern = re.compile(r'(\w+)\t(\d+)')
if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
print("This script must be run as the root or rabbitmq user")
output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_queues'], universal_newlines=True)
status = 0
max_count = 0
warn_queues = []
if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
print("This script must be run as the root or rabbitmq user")
for line in output.split("\n"):
line = line.strip()
m = pattern.match(line)