From d21be42946b4b3cd05dfaf961fea600627e9dc15 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Mon, 18 Feb 2013 20:36:59 -0500 Subject: [PATCH] [manual] tools: Move check_output into a shared file We leave the stuff under api/ alone for now, since we need to be able to ship it as a standalone thing. tools/post-receive wasn't using the function anyway. For push to master: Push this commit, update post-receive per instructions at the top of that file, then push the rest of the branch to confirm that the hook still works. No manual instructions for prod. (imported from commit 9bcbe14c08d15eda47d82f0b702bad33e217a074) --- bots/check-rabbitmq-queue | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/bots/check-rabbitmq-queue b/bots/check-rabbitmq-queue index c0a515a..79f3bd1 100755 --- a/bots/check-rabbitmq-queue +++ b/bots/check-rabbitmq-queue @@ -5,6 +5,11 @@ import subprocess import re import time +from os import path + +sys.path.append(path.join(path.dirname(__file__), '../tools')) +from humbug_tools import check_output + WARN_THRESHOLD = 100 CRIT_THRESHOLD = 200 @@ -15,23 +20,8 @@ states = { 3: "UNKNOWN" } -# check_output is backported from subprocess.py in Python 2.7 -def check_output(*popenargs, **kwargs): - if 'stdout' in kwargs: - raise ValueError('stdout argument not allowed, it will be overridden.') - process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) - output, unused_err = process.communicate() - retcode = process.poll() - if retcode: - cmd = kwargs.get("args") - if cmd is None: - cmd = popenargs[0] - raise subprocess.CalledProcessError(retcode, cmd, output=output) - return output -subprocess.check_output = check_output - re = re.compile(r'(\w+)\t(\d+)') -output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_queues'], shell=False) +output = check_output(['/usr/sbin/rabbitmqctl', 'list_queues'], shell=False) status = 0 max_count = 0