From 05c01c358cfac28061ef0f028f25c408e02487ed Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sun, 28 Jun 2020 20:49:39 +0000 Subject: Add a column showing mageia_timestamp age This gives a better idea on how long ago the mirror last (at least partially) synced than VERSION which only changes after an upload. --- modules/mga-mirrors/files/check_mirrors_status | 64 +++++++++++++++++--------- 1 file changed, 43 insertions(+), 21 deletions(-) (limited to 'modules/mga-mirrors') diff --git a/modules/mga-mirrors/files/check_mirrors_status b/modules/mga-mirrors/files/check_mirrors_status index 867ff3ec..0e23eeca 100755 --- a/modules/mga-mirrors/files/check_mirrors_status +++ b/modules/mga-mirrors/files/check_mirrors_status @@ -8,6 +8,11 @@ require 'uri' def get_dates(base, archs_per_distro, optional=true) r = {} + begin + r['base'] = get_timestamp(base) + rescue Net::OpenTimeout, Timeout::Error, ArgumentError, NoMethodError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, IOError => e + end + archs_per_distro.each{|d, archs| r[d] = {} archs.each{|a| @@ -29,7 +34,9 @@ def get_mirrors mirrors = [] fetch_url("http://mirrors.mageia.org/").each_line{|l| next unless l =~ /http:.*>http/ - mirrors << l.sub(/X" unless time + + diff = time - ref_time + cls = nil + if diff == 0 then + cls = 'ok' + elsif diff < 0.5 then + cls = 'almost' + elsif diff < 2 then + cls = 'bad' + end + if cls == 'ok' then + return "  " + else + return " #{time.strftime("%F %R")}" + end +end + def print_output(archs_per_distro, mirrors, ref_times, times) puts "