2015-10-04 18:56:26 +02:00
|
|
|
#!/usr/bin/env python2.7
|
2013-11-13 01:52:40 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
Shows backlog count of ScheduledJobs of type Email
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-11-13 01:52:40 +01:00
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
|
|
|
from zerver.models import ScheduledJob
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = """Shows backlog count of ScheduledJobs of type Email
|
|
|
|
(The number of currently overdue (by at least a minute) email jobs)
|
|
|
|
|
|
|
|
This is run as part of the nagios health check for the deliver_email command.
|
2015-08-21 18:34:54 +02:00
|
|
|
Please note that this is only relevant to the SMTP-based email delivery (no Mandrill).
|
2013-11-13 01:52:40 +01:00
|
|
|
|
2015-10-04 18:56:26 +02:00
|
|
|
Usage: python2.7 manage.py print_email_delivery_backlog
|
2013-11-13 01:52:40 +01:00
|
|
|
"""
|
|
|
|
|
2013-11-13 22:59:04 +01:00
|
|
|
def handle(self, *args, **options):
|
2015-11-01 17:11:06 +01:00
|
|
|
print(len(ScheduledJob.objects.filter(type=ScheduledJob.EMAIL,
|
|
|
|
scheduled_timestamp__lte=datetime.utcnow()-timedelta(minutes=1))))
|
2013-11-13 01:52:40 +01:00
|
|
|
return
|
|
|
|
|