From b8825646355e3cf251e2c40dc239edc6056b702f Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Fri, 6 Feb 2015 18:52:20 +0100 Subject: [PATCH] command checking services status Closes #6445 --- .../management/commands/check_operational.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 hobo/environment/management/commands/check_operational.py 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)