Skip to content

Instantly share code, notes, and snippets.

@vmihailenco
Created March 6, 2012 14:04
Show Gist options
  • Save vmihailenco/1986448 to your computer and use it in GitHub Desktop.
Save vmihailenco/1986448 to your computer and use it in GitHub Desktop.
Django command to monitor celeryd
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