Projet

Général

Profil

0001-command-checking-services-status.patch

Serghei Mihai (congés, retour 15/05), 06 février 2015 20:04

Télécharger (1,52 ko)

Voir les différences:

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
hobo/environment/management/commands/check_operational.py
1
from optparse import make_option
2

  
3
from django.core.management.base import BaseCommand
4

  
5
from hobo.environment import models
6

  
7
class Command(BaseCommand):
8
    help = '''Checks if all services are operational'''
9

  
10
    def handle(self, *args, **kwargs):
11
        for klass in models.AVAILABLE_SERVICES:
12
            for obj in klass.objects.all():
13
                obj.check_operational()
14
                if int(kwargs.get('verbosity')) > 1:
15
                    if obj.is_operational():
16
                        print("%s is operational" % obj.title)
17
                    else:
18
                        print self.style.NOTICE('%s is still NOT operational' % obj.title)
19
                        if obj.last_operational_success_timestamp:
20
                            print self.style.NOTICE('  last operational success: %s' % obj.last_operational_success_timestamp)
0
-