diff --git a/hobo/environment/management/commands/check_operational.py b/hobo/environment/management/commands/check_operational.py new file mode 100644 index 0000000..e58fdda --- /dev/null +++ b/hobo/environment/management/commands/check_operational.py @@ -0,0 +1,20 @@ +from optparse import make_option + +from django.core.management.base import BaseCommand + +from hobo.environment import models + +class Command(BaseCommand): + help = '''Checks if all services are operational''' + + def handle(self, *args, **kwargs): + for klass in models.AVAILABLE_SERVICES: + for obj in klass.objects.all(): + obj.check_operational() + if int(kwargs.get('verbosity')) > 1: + if obj.is_operational(): + print("%s is operational" % obj.title) + else: + print self.style.NOTICE('%s is NOT operational' % obj.title) + if obj.last_operational_success_timestamp: + print self.style.NOTICE(' last operational success: %s' % obj.last_operational_success_timestamp)