Add ability to restrict status report to single tier
This should make it easier to catch errors in our Tier 1 mirrors. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
2f7d770b26
commit
ae1c526ffb
@ -4,6 +4,7 @@
|
||||
(r'^$', 'mirrors', {}, 'mirror-list'),
|
||||
(r'^status/$', 'status', {}, 'mirror-status'),
|
||||
(r'^status/json/$', 'status_json', {}, 'mirror-status-json'),
|
||||
(r'^status/tier/(?P<tier>\d+)/$', 'status', {}, 'mirror-status-tier'),
|
||||
(r'^(?P<name>[\.\-\w]+)/$', 'mirror_details'),
|
||||
)
|
||||
|
||||
|
@ -88,7 +88,7 @@ def get_mirror_errors(cutoff=default_cutoff):
|
||||
is_success=False, check_time__gte=cutoff_time,
|
||||
url__mirror__active=True, url__mirror__public=True).values(
|
||||
'url__url', 'url__country', 'url__protocol__protocol',
|
||||
'url__mirror__country', 'error').annotate(
|
||||
'url__mirror__country', 'url__mirror__tier', 'error').annotate(
|
||||
error_count=Count('error'), last_occurred=Max('check_time')
|
||||
).order_by('-last_occurred', '-error_count')
|
||||
errors = list(errors)
|
||||
|
@ -13,7 +13,7 @@
|
||||
from django.views.generic.simple import direct_to_template
|
||||
from django_countries.countries import COUNTRIES
|
||||
|
||||
from .models import Mirror, MirrorUrl, MirrorProtocol
|
||||
from .models import Mirror, MirrorUrl, MirrorProtocol, TIER_CHOICES
|
||||
from .utils import get_mirror_statuses, get_mirror_errors
|
||||
|
||||
COUNTRY_LOOKUP = dict(COUNTRIES)
|
||||
@ -184,7 +184,11 @@ def mirror_details(request, name):
|
||||
{'mirror': mirror, 'urls': all_urls})
|
||||
|
||||
|
||||
def status(request):
|
||||
def status(request, tier=None):
|
||||
if tier is not None:
|
||||
tier = int(tier)
|
||||
if tier not in [t[0] for t in TIER_CHOICES]:
|
||||
raise Http404
|
||||
bad_timedelta = timedelta(days=3)
|
||||
status_info = get_mirror_statuses()
|
||||
|
||||
@ -192,17 +196,26 @@ def status(request):
|
||||
good_urls = []
|
||||
bad_urls = []
|
||||
for url in urls:
|
||||
# screen by tier if we were asked to
|
||||
if tier is not None and url.mirror.tier != tier:
|
||||
continue
|
||||
# split them into good and bad lists based on delay
|
||||
if not url.delay or url.delay > bad_timedelta:
|
||||
bad_urls.append(url)
|
||||
else:
|
||||
good_urls.append(url)
|
||||
|
||||
error_logs = get_mirror_errors()
|
||||
if tier is not None:
|
||||
error_logs = [log for log in error_logs
|
||||
if log['url__mirror__tier'] == tier]
|
||||
|
||||
context = status_info.copy()
|
||||
context.update({
|
||||
'good_urls': sorted(good_urls, key=attrgetter('score')),
|
||||
'bad_urls': sorted(bad_urls, key=lambda u: u.delay or timedelta.max),
|
||||
'error_logs': get_mirror_errors(),
|
||||
'error_logs': error_logs,
|
||||
'tier': tier,
|
||||
})
|
||||
return direct_to_template(request, 'mirrors/status.html', context)
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
{% load static from staticfiles %}
|
||||
{% load mirror_status %}
|
||||
|
||||
{% block title %}Arch Linux - Mirror Status{% endblock %}
|
||||
{% block title %}Arch Linux - Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="mirrorstatus" class="box">
|
||||
<h2>Mirror Status</h2>
|
||||
<h2>Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}</h2>
|
||||
<p>This page reports the status of all known, public, and active Arch Linux
|
||||
mirrors. All data on this page reflects the status of the mirrors within
|
||||
the <em>last {{ cutoff|hours }}</em>. All listed times are UTC. The check script runs
|
||||
|
Loading…
Reference in New Issue
Block a user