diff --git a/apps/amo/templates/services/monitor.html b/apps/amo/templates/services/monitor.html index 4c85339470..e07a6fb602 100644 --- a/apps/amo/templates/services/monitor.html +++ b/apps/amo/templates/services/monitor.html @@ -51,7 +51,7 @@
-

Redis Info

+

[Redis] Redis Info

{% with info, error = redis_results %} {% if info %}
+
+

[Zeus] Connection Tests (Hera)

+ +
+ {% endblock main_content %} diff --git a/apps/amo/views.py b/apps/amo/views.py index 3433ec7a5f..a19fec9dfe 100644 --- a/apps/amo/views.py +++ b/apps/amo/views.py @@ -2,6 +2,7 @@ import os import random import socket import urllib2 +from urlparse import urlparse from django import http from django.conf import settings @@ -14,8 +15,7 @@ import commonware.log import jingo import phpserialize as php -from amo.urlresolvers import reverse -from api.views import render_xml +from hera.contrib.django_utils import get_hera from stats.models import Contribution, ContributionError, SubscriptionEvent from . import log @@ -84,11 +84,22 @@ def monitor(request): status_summary['filepaths'] = filepath_status + # Check Redis redis_results = [None, 'REDIS_BACKEND is not set'] if getattr(settings, 'REDIS_BACKEND', False): redis_results = check_redis() status_summary['redis'] = bool(redis_results[0]) + # Check Hera + hera_results = [] + status_summary['hera'] = True + for i in settings.HERA: + r = {'location': urlparse(i['LOCATION'])[1], + 'result': bool(get_hera(i))} + hera_results.append(r) + if not hera_results[-1]['result']: + status_summary['hera'] = False + # If anything broke, send HTTP 500 if not all(status_summary): status = 500 @@ -97,6 +108,7 @@ def monitor(request): {'memcache_results': memcache_results, 'filepath_results': filepath_results, 'redis_results': redis_results, + 'hera_results': hera_results, 'status_summary': status_summary}, status=status) diff --git a/apps/zadmin/templates/zadmin/hera.html b/apps/zadmin/templates/zadmin/hera.html index 04c8b1dff6..bac841a1ad 100644 --- a/apps/zadmin/templates/zadmin/hera.html +++ b/apps/zadmin/templates/zadmin/hera.html @@ -46,19 +46,22 @@

Stats

- {% if stats %} - {% if stats.num_lookups > 0 %} - {# Can't jinja2 detect a division by zero and just do something intelligent? #} - {% set hit_percentage = stats.num_hits / stats.num_lookups %} - {% else %} - {% set hit_percentage = 0 %} - {% endif %} - - {% else %} -

Not Available

- {% endif %} + {% for i in boxes %} +

{{ i.location }}

+ {% if i.stats %} + {% if i.stats.num_lookups > 0 %} + {# Can't jinja2 detect a division by zero and just do something intelligent? #} + {% set hit_percentage = i.stats.num_hits / i.stats.num_lookups %} + {% else %} + {% set hit_percentage = 0 %} + {% endif %} + + {% else %} +

Not Available

+ {% endif %} + {% endfor %}
{% endblock %} diff --git a/apps/zadmin/views.py b/apps/zadmin/views.py index 7153cc80ca..3c4ced4b41 100644 --- a/apps/zadmin/views.py +++ b/apps/zadmin/views.py @@ -1,3 +1,5 @@ +from urlparse import urlparse + from django import http # I'm so glad we named a function in here settings... from django.conf import settings as site_settings @@ -65,14 +67,19 @@ def flagged(request): def hera(request): form = FlushForm(initial={'flushprefix': site_settings.SITE_URL}) - hera = get_hera() + boxes = [] + configured = False # Default to not showing the form. + for i in site_settings.HERA: + hera = get_hera(i) + r = {'location': urlparse(i['LOCATION'])[1], 'stats': False} + if hera: + r['stats'] = hera.getGlobalCacheInfo() + configured = True + boxes.append(r) - if not hera: + if not configured: messages.error(request, "Hera is not (or mis-)configured.") form = None - stats = None - else: - stats = hera.getGlobalCacheInfo() if request.method == 'POST' and hera: form = FlushForm(request.POST) @@ -87,7 +94,7 @@ def hera(request): messages.success(request, msg) return jingo.render(request, 'zadmin/hera.html', - {'form': form, 'stats': stats}) + {'form': form, 'boxes': boxes}) @admin.site.admin_view diff --git a/settings.py b/settings.py index f418db2414..9fd20e88da 100644 --- a/settings.py +++ b/settings.py @@ -472,10 +472,10 @@ CUSTOM_DUMPS = { } ## Hera (http://github.com/clouserw/hera) -HERA = {'USERNAME': '', +HERA = [{'USERNAME': '', 'PASSWORD': '', 'LOCATION': '', - } + }] # Logging LOG_LEVEL = logging.DEBUG