Beispiel #1
0
from django.conf import settings

from moj_irat.healthchecks import UrlHealthcheck, registry


registry.register_healthcheck(UrlHealthcheck(
    name='mapit',
    url='%sSW1A+1AA' % settings.MAPIT_BASE_URL,
    value_at_json_path=('SW1A 1AA', 'postcode'),
))
registry.register_healthcheck(UrlHealthcheck(
    name='courtfinder_admin',
    url=settings.COURTFINDER_ADMIN_HEALTHCHECK_URL,
))
from django.conf import settings

from moj_irat.healthchecks import UrlHealthcheck, registry

registry.register_healthcheck(UrlHealthcheck(
    name='mapit',
    url='%sSW1A+1AA' % settings.MAPIT_BASE_URL,
    value_at_json_path=('SW1A 1AA', 'postcode'),
    headers={'X-Api-Key': settings.MAPTI_API_KEY}
))
Beispiel #3
0
            if not stats:
                return self.error_response("No running workers were found.")

            workers = stats.values()
            if not workers:
                return self.error_response("No workers running.")

        except IOError as e:
            msg = str(e)
            msg += ". Check that the message broker is running."
            return self.error_response(msg)

        except ImportError as e:
            return self.error_response(str(e))

        return self.success_response()

    def error_response(self, error):
        return HealthcheckResponse(self.name, False, error=error)

    def success_response(self):
        return HealthcheckResponse(self.name, True)


registry.register_healthcheck(
    UrlHealthcheck(name="postcodes.io",
                   url="{}/postcodes/SW1A1AA".format(
                       settings.POSTCODES_IO_URL)))

registry.register_healthcheck(CeleryWorkersHealthcheck(name="workers"))
from django.conf import settings

from moj_irat.healthchecks import HealthcheckResponse, JsonUrlHealthcheck, \
    UrlHealthcheck, registry
from zendesk_tickets.client import zendesk_auth

registry.register_healthcheck(JsonUrlHealthcheck(
    name='api',
    url='%s/healthcheck.json' % settings.API_URL,
    value_at_json_path=(True, '*.status'),
))

if settings.ZENDESK_API_USERNAME and settings.ZENDESK_API_TOKEN and \
        settings.ZENDESK_GROUP_ID:
    registry.register_healthcheck(UrlHealthcheck(
        name='zendesk',
        url='%(base_url)s/api/v2/groups/%(group_id)s.json' % {
            'base_url': settings.ZENDESK_BASE_URL,
            'group_id': settings.ZENDESK_GROUP_ID,
        },
        headers={'Content-Type': 'application/json'},
        auth=zendesk_auth(),
        value_at_json_path=(settings.ZENDESK_GROUP_ID, 'group.id')
    ))
else:
    registry.register_healthcheck(lambda: HealthcheckResponse(
        name='zendesk',
        status=False,
        error='Zendesk API settings not specified',
    ))
from django.conf import settings

from moj_irat.healthchecks import HealthcheckResponse, JsonUrlHealthcheck, \
    UrlHealthcheck, registry
from zendesk_tickets.client import zendesk_auth

registry.register_healthcheck(
    JsonUrlHealthcheck(
        name='api',
        url='%s/healthcheck.json' % settings.API_URL,
        value_at_json_path=(True, '*.status'),
    ))

if settings.ZENDESK_API_USERNAME and settings.ZENDESK_API_TOKEN and \
        settings.ZENDESK_GROUP_ID:
    registry.register_healthcheck(
        UrlHealthcheck(name='zendesk',
                       url='%(base_url)s/api/v2/groups/%(group_id)s.json' % {
                           'base_url': settings.ZENDESK_BASE_URL,
                           'group_id': settings.ZENDESK_GROUP_ID,
                       },
                       headers={'Content-Type': 'application/json'},
                       auth=zendesk_auth(),
                       value_at_json_path=(settings.ZENDESK_GROUP_ID,
                                           'group.id')))
else:
    registry.register_healthcheck(lambda: HealthcheckResponse(
        name='zendesk',
        status=False,
        error='Zendesk API settings not specified',
    ))

class PassingExtraResponseHealthcheck(object):
    def __call__(self, *args, **kwargs):
        return HealthcheckResponse('class_extra', True,
                                   extra='extra message')


@_track_calls
def error_healthcheck():
    raise ValueError('error')


@_track_calls
def passing_bool_healthcheck():
    return True


@_track_calls
def failing_bool_healthcheck():
    return False


failing_bool_healthcheck.name = 'failing_bool'

registry.register_healthcheck(PassingResponseHealthcheck)
registry.register_healthcheck(PassingExtraResponseHealthcheck)
registry.register_healthcheck(passing_bool_healthcheck)
registry.register_healthcheck(failing_bool_healthcheck)
registry.register_healthcheck(error_healthcheck)
from django.conf import settings

from moj_irat.healthchecks import UrlHealthcheck, registry

registry.register_healthcheck(
    UrlHealthcheck(name='mapit',
                   url='%sSW1A+1AA' % settings.MAPIT_BASE_URL,
                   value_at_json_path=('SW1A 1AA', 'postcode'),
                   headers={'X-Api-Key': settings.MAPTI_API_KEY}))