From b892e99d27e8b51b89ea3a2641ee78f3d105b38a 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 --- .../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..86ae1b1 --- /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 still NOT operational' % obj.title) + if obj.last_operational_success_timestamp: + print self.style.NOTICE(' last operational success: %s' % obj.last_operational_success_timestamp) -- 2.1.4