Created
March 6, 2012 14:04
-
-
Save vmihailenco/1986448 to your computer and use it in GitHub Desktop.
Django command to monitor celeryd
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
import sys | |
from django.core.management.base import BaseCommand | |
from celery.task.control import ping | |
class Command(BaseCommand): | |
def ok(self, message): | |
self.stdout.write('OK: %s' % message) | |
sys.exit(0) | |
def warning(self, message): | |
self.stdout.write('WARNING: %s' % message) | |
sys.exit(1) | |
def critical(self, message): | |
self.stdout.write('CRITICAL: %s' % message) | |
sys.exit(2) | |
def handle(self, *args, **options): | |
rl = ping() | |
if not rl: | |
self.critical('celery is down') | |
for r in rl: | |
for name, resp in r.items(): | |
if resp != 'pong': | |
self.critical( | |
'ping %s: got %r (expected "pong")' % (name, resp)) | |
self.ok(repr(rl)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment