From 07d8c7a53af0b28aac542d5135cc63ad1a2a7b7b Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 4 Jan 2020 11:02:47 +0100 Subject: started HMTL version of mirror status --- mirrors.php | 116 +++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 83 insertions(+), 33 deletions(-) (limited to 'mirrors.php') diff --git a/mirrors.php b/mirrors.php index 0a57ce6..40a54f3 100644 --- a/mirrors.php +++ b/mirrors.php @@ -26,7 +26,7 @@ array_splice( if (count($uri_parts) == 0) { // index $cutoff = 3600; - + $sorts = array( "server" => array( "title" => "server", @@ -52,7 +52,7 @@ if (count($uri_parts) == 0) { // index $query = "SELECT " . - "GROUP_CONCAT(`l_ms`.`protocol`) AS `protocols`," . + "GROUP_CONCAT(DISTINCT `l_ms`.`protocol`) AS `protocols`," . "SUBSTRING(`l_ms`.`url`,LENGTH(`l_ms`.`protocol`)+4) AS `url`," . "`l_ms`.`country`," . "`l_ms`.`country_code`," . @@ -121,30 +121,34 @@ if (count($uri_parts) == 0) { // index \n"; - print " \n"; - print " " . $row["url"] . "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " " . $row["country"] . "\n"; - print " \n"; - print " \n"; - if ($row["isos"]) - print " Yes\n"; - else - print " No\n"; - print " \n"; - print " \n"; - print " " . $row["protocols"] . "\n"; - print " \n"; - print " \n"; - if ($oddity == "odd") - $oddity = "even"; - else - $oddity = "odd"; + if (isset($rows)) { + foreach ($rows as $row) { + print " \n"; + print " \n"; + print " " . $row["url"] . "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " " . $row["country"] . "\n"; + print " \n"; + print " \n"; + if ($row["isos"]) + print " Yes\n"; + else + print " No\n"; + print " \n"; + print " \n"; + print " " . $row["protocols"] . "\n"; + print " \n"; + print " \n"; + if ($oddity == "odd") + $oddity = "even"; + else + $oddity = "odd"; + } + } else { + print "There is no data, as no mirror checks run in the last " . $cutoff . " seconds."; } ?> @@ -160,7 +164,8 @@ if (count($uri_parts) == 0) { // index if ($uri_parts[0] == 'status') { - $cutoff = 86400; +// $cutoff = 86400; + $cutoff = 120000; $result = mysql_run_query( "SELECT " . @@ -228,18 +233,63 @@ if ($uri_parts[0] == 'status') { $content = array( "cutoff" => $cutoff, - "check_frequency" => $cutoff/$max_count, + "check_frequency" => (($max_count!=0)?($cutoff/$max_count):0), "num_checks" => $max_count, "last_check" => gmdate("Y-m-d\TH:i:s.v\Z",$last_check), //"2018-06-15T07:25:06.741Z", // "version" => 3, - "urls" => $urls + "urls" => (isset($urls)?$urls:[]) ); if (count($uri_parts) == 1) { // human readable - // TODO - header('HTTP/1.1 303 See Other'); - header('Location: /mirrors/status/json/'); - die(); + print_header("Mirror Status"); + print << +

Mirror Status

+EOF; + if ($max_count==0) { + print "No results as there was no mirror check running in the last " . $cutoff . " seconds."; + } else { + print << + This page reports the status of all known, public, and active ArchLinux32 mirrors. + All data on this page reflects the status of the mirrors within the last $cutoff seconds. + All listed times are UTC. The check script runs on a regular basis and polls for + the lastsync file in the root of our repository layout. This file is regularly + updated on the central repository, so checking the value within allows one + to see if the mirror has synced recently. This page contains several pieces + of information about each mirror. +

+

+ The last mirror check ran at ${content['last_check']} UTC. + Checks have ran ${content['num_checks']} times in the last + $cutoff seconds at an average interval of ${content['check_frequency']} seconds. +

+

+ This data is also available in JSON + or TSV format. The units of all + time/duration values are in seconds; date/time values are UTC. +

+

Successfully Syncing Mirrors

+ + + +protocol url country country_code last_sync start delay duration_avg duration_stddev isos ipv4 ipv6 active recently_active completion_pct count score +EOF; + print << + +
+EOF; + print << +
+EOF;
+    }
+    print json_encode($content, JSON_PRETTY_PRINT);
+    print <<
+EOF;
+    exit( );
   } // human readable
 
   if (!export_as_requested(
-- 
cgit v1.2.3