예제 #1
0
파일: health.py 프로젝트: Kayle009/sentry
    def process_request(self, request):
        # Our health check can't be a done as a view, because we need
        # to bypass the ALLOWED_HOSTS check. We need to do this
        # since not all load balancers can send the expected Host header
        # which would cause a 400 BAD REQUEST, marking the node dead.
        # Instead, we just intercept the request at this point, and return
        # our success/failure immediately.
        if request.path != '/_health/':
            return

        if 'full' not in request.GET:
            return HttpResponse('ok', content_type='text/plain')

        from sentry.status_checks import Problem, check_all
        from sentry.utils import json

        threshold = Problem.threshold(Problem.SEVERITY_CRITICAL)
        results = {check: filter(threshold, problems) for check, problems in check_all().items()}
        problems = list(itertools.chain.from_iterable(results.values()))

        return HttpResponse(
            json.dumps(
                {
                    'problems': [six.text_type(p) for p in problems],
                    'healthy': {type(check).__name__: not p for check, p in results.items()},
                }
            ),
            content_type='application/json',
            status=(500 if problems else 200)
        )
예제 #2
0
def show_system_status(context):
    problems = itertools.chain.from_iterable(
        status_checks.check_all().values(),
    )
    return {
        'problems': sort_by_severity(problems),
    }
예제 #3
0
def show_system_status(context):
    problems = itertools.chain.from_iterable(
        status_checks.check_all().values(),
    )
    return {
        'problems': sort_by_severity(problems),
    }
예제 #4
0
    def process_request(self, request):
        # Our health check can't be a done as a view, because we need
        # to bypass the ALLOWED_HOSTS check. We need to do this
        # since not all load balancers can send the expected Host header
        # which would cause a 400 BAD REQUEST, marking the node dead.
        # Instead, we just intercept the request at this point, and return
        # our success/failure immediately.
        if request.path != "/_health/":
            return

        if "full" not in request.GET:
            return HttpResponse("ok", content_type="text/plain")

        from sentry.status_checks import Problem, check_all
        from sentry.utils import json

        threshold = Problem.threshold(Problem.SEVERITY_CRITICAL)
        results = {
            check: filter(threshold, problems)
            for check, problems in check_all().items()
        }
        problems = list(itertools.chain.from_iterable(results.values()))

        return HttpResponse(
            json.dumps({
                "problems": [six.text_type(p) for p in problems],
                "healthy":
                {type(check).__name__: not p
                 for check, p in results.items()},
            }),
            content_type="application/json",
            status=(500 if problems else 200),
        )
예제 #5
0
def show_system_status(context):
    problems = list(
        itertools.chain.from_iterable(status_checks.check_all().values()))

    return {
        'problems': problems,
    }
예제 #6
0
    def get(self, request):
        problems, checks = status_checks.check_all()

        return Response({
            'problems': map(unicode, problems),
            'healthy': checks,
        })
예제 #7
0
파일: urls.py 프로젝트: rebeckag/sentry
def handler_healthcheck(request):
    if request.GET.get('full'):

        problems, checks = status_checks.check_all()
        return HttpResponse(json.dumps({
            'problems': map(unicode, problems),
            'healthy': checks,
        }), content_type='application/json', status=(500 if problems else 200))
예제 #8
0
파일: urls.py 프로젝트: JTCunning/sentry
def handler_healthcheck(request):
    if request.GET.get('full'):

        problems = status_checks.check_all()
        if problems:
            return HttpResponse(json.dumps({
                'problems': map(unicode, problems),
            }), content_type='application/json', status=500)
    return HttpResponse('ok')
예제 #9
0
def handler_healthcheck(request):
    if request.GET.get('full'):

        problems, checks = status_checks.check_all()
        return HttpResponse(json.dumps({
            'problems': map(unicode, problems),
            'healthy': checks,
        }),
                            content_type='application/json',
                            status=(500 if problems else 200))
예제 #10
0
 def get(self, request):
     results = status_checks.check_all()
     return Response({
         'problems': map(
             lambda problem: {
                 'message': problem.message,
                 'severity': problem.severity,
             },
             itertools.chain.from_iterable(results.values()),
         ),
         'healthy': {type(check).__name__: not problems for check, problems in results.items()},
     })
예제 #11
0
파일: urls.py 프로젝트: nagyistoce/sentry
def handler_healthcheck(request):
    problems, checks = status_checks.check_all()

    if request.GET.get("full"):
        return HttpResponse(
            json.dumps({"problems": map(unicode, problems), "healthy": checks}),
            content_type="application/json",
            status=(500 if problems else 200),
        )
    elif problems:
        return handler500(request)
    else:
        return HttpResponse("ok")
예제 #12
0
 def get(self, request):
     results = status_checks.check_all()
     return Response({
         'problems': [
             {
                 'id': md5_text(problem.message).hexdigest(),
                 'message': problem.message,
                 'severity': problem.severity,
                 'url': problem.url,
             }
             for problem in sorted(itertools.chain.from_iterable(results.values()),
                                  reverse=True)
         ],
         'healthy': {type(check).__name__: not problems for check, problems in results.items()},
     })
예제 #13
0
 def get(self, request):
     results = status_checks.check_all()
     return Response({
         'problems': [{
             'id': md5_text(problem.message).hexdigest(),
             'message': problem.message,
             'severity': problem.severity,
             'url': problem.url,
         } for problem in sort_by_severity(
             itertools.chain.from_iterable(results.values()))],
         'healthy': {
             type(check).__name__: not problems
             for check, problems in results.items()
         },
     })
예제 #14
0
 def get(self, request):
     results = status_checks.check_all()
     return Response(
         {
             "problems": map(
                 lambda problem: {
                     "id": md5(problem.message).hexdigest(),
                     "message": problem.message,
                     "severity": problem.severity,
                     "url": problem.url,
                 },
                 sorted(itertools.chain.from_iterable(results.values()), reverse=True),
             ),
             "healthy": {type(check).__name__: not problems for check, problems in results.items()},
         }
     )
예제 #15
0
 def get(self, request):
     results = status_checks.check_all()
     return Response({
         'problems':
         map(
             lambda problem: {
                 'message': problem.message,
                 'severity': problem.severity,
                 'url': problem.url,
             },
             itertools.chain.from_iterable(results.values()),
         ),
         'healthy': {
             type(check).__name__: not problems
             for check, problems in results.items()
         },
     })
예제 #16
0
    def get(self, request):
        if not is_active_superuser(request):
            return Response()

        results = status_checks.check_all()
        return Response({
            "problems": [{
                "id": md5_text(problem.message).hexdigest(),
                "message": problem.message,
                "severity": problem.severity,
                "url": problem.url,
            } for problem in sort_by_severity(
                itertools.chain.from_iterable(results.values()))],
            "healthy": {
                type(check).__name__: not problems
                for check, problems in results.items()
            },
        })
예제 #17
0
    def process_request(self, request):
        # Our health check can't be a done as a view, because we need
        # to bypass the ALLOWED_HOSTS check. We need to do this
        # since not all load balancers can send the expected Host header
        # which would cause a 400 BAD REQUEST, marking the node dead.
        # Instead, we just intercept the request at this point, and return
        # our success/failure immediately.
        if request.path != '/_health/':
            return

        if 'full' not in request.GET:
            return HttpResponse('ok', content_type='text/plain')

        from sentry.status_checks import check_all
        from sentry.utils import json
        problems, checks = check_all()

        return HttpResponse(json.dumps({
            'problems': map(unicode, problems),
            'healthy': checks,
        }),
                            content_type='application/json',
                            status=(500 if problems else 200))
예제 #18
0
def show_system_status(context):
    problems, _ = status_checks.check_all()

    return {
        'problems': problems,
    }
예제 #19
0
def show_system_status(context):
    problems, _ = status_checks.check_all()

    return {
        'problems': problems,
    }
예제 #20
0
def show_system_status(context):
    problems = list(itertools.chain.from_iterable(status_checks.check_all().values()))

    return {
        'problems': problems,
    }