@@ -0,0 +1,888 @@
+#!/usr/bin/python%0A%0A%22%22%22%0AShows backlog count of ScheduledJobs of type Email%0A%22%22%22%0A%0Afrom __future__ import absolute_import%0A%0Afrom django.conf import settings%0Afrom django.core.management.base import BaseCommand%0A%0Afrom zerver.models import ScheduledJob%0A%0Afrom datetime import datetime, timedelta%0A%0Aclass Command(BaseCommand):%0A    help = %22%22%22Shows backlog count of ScheduledJobs of type Email%0A(The number of currently overdue (by at least a minute) email jobs)%0A%0AThis is run as part of the nagios health check for the deliver_email command.%0APlease note that this is only currently useful for Zulip Enterprise deploys.%0A%0AUsage: python manage.py print_email_delivery_backlog%0A%22%22%22%0A%0A    def handle(self):%0A        print len(ScheduledJob.objects.filter(type=ScheduledJob.EMAIL,%0A                                                  scheduled_timestamp__lte=datetime.utcnow()-timedelta(minutes=1)))%0A        return%0A%0A

add print_email_delivery_backlog for nagios reasons