array(
"title" => "server",
"label" => "Server",
"mysql" => "`url`"
),
"country" => array(
"title" => "country",
"label" => "Country",
"mysql" => "`l_ms`.`country_code`"
),
"isos" => array(
"title" => "wether isos are available",
"label" => "ISOs",
"mysql" => "`l_ms`.`isos`"
),
"protocols" => array(
"title" => "available protocols",
"label" => "Protocols",
"mysql" => "`protocols`"
)
);
$query =
"SELECT " .
"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`," .
"`l_ms`.`isos`," .
"`l_ms`.`ipv4`," .
"`l_ms`.`ipv6`" .
" FROM (" .
"SELECT " .
"`mirror_statuses`.`url`," .
"MAX(`mirror_statuses`.`start`) AS `start`" .
" FROM `mirror_statuses`" .
" WHERE `mirror_statuses`.`start` > UNIX_TIMESTAMP(NOW())-" . $cutoff .
" GROUP BY `mirror_statuses`.`url`" .
") AS `ls`" .
" JOIN `mirror_statuses` AS `l_ms`" .
" ON `ls`.`url`=`l_ms`.`url`" .
" AND `ls`.`start`=`l_ms`.`start`" .
" GROUP BY `url`" .
" ORDER BY ";
if (array_key_exists("sort", $_GET)) {
if (isset($sorts[$_GET["sort"]]["mysql"]))
$query .= $sorts[$_GET["sort"]]["mysql"] . ",";
elseif (isset($sorts[substr($_GET["sort"],1)]["mysql"]))
$query .= $sorts[substr($_GET["sort"],1)]["mysql"] . " DESC,";
}
$query .= "`url`";
$result = mysql_run_query(
$query
);
$last_check = 0;
$max_count = 0;
while($row = $result->fetch_assoc())
$rows[] = $row;
print_header("Mirror Overview");
?>
Mirror Overview
$sort) {
print " \n";
print " ".$sort["label"]."\n";
print " | \n";
}
?>
\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.";
}
?>
UNIX_TIMESTAMP(NOW()) - 3600)) AS `recently_active`," .
"AVG(IF(`a_ms`.`active`,1,0)) AS `completion_pct`," .
"COUNT(1) AS `count`" .
" FROM (" .
"SELECT " .
"`mirror_statuses`.`url`," .
"MAX(`mirror_statuses`.`start`) AS `start`" .
" FROM `mirror_statuses`" .
" WHERE `mirror_statuses`.`start` > UNIX_TIMESTAMP(NOW())-" . $cutoff .
" GROUP BY `mirror_statuses`.`url`" .
") AS `ls`" .
" JOIN `mirror_statuses` AS `l_ms`" .
" ON `ls`.`url`=`l_ms`.`url`" .
" AND `ls`.`start`=`l_ms`.`start`" .
" JOIN `mirror_statuses` AS `a_ms`" .
" ON `a_ms`.`url`=`l_ms`.`url`" .
" AND `a_ms`.`start` > UNIX_TIMESTAMP(NOW())-" . $cutoff .
" GROUP BY `l_ms`.`id`"
);
$last_check = 0;
$max_count = 0;
while($row = $result->fetch_assoc()) {
foreach (array(
"start",
"delay",
"duration_avg",
"duration_stddev",
"completion_pct",
"count",
"isos",
"ipv4",
"ipv6",
"active",
"recently_active"
) as $key)
$row[$key] = floatval($row[$key]);
$row["last_sync"] = gmdate("Y-m-d\TH:i:s\Z", $row["last_sync"]);
if ($row["completion_pct"] == 0)
$row["score"] = 0;
else
$row["score"] =
($row["delay"] + $row["duration_avg"] + $row["duration_stddev"]) / $row["completion_pct"];
$urls[] = $row;
$last_check = max ($row["start"], $last_check);
$max_count = max ($row["count"], $max_count);
}
$content = array(
"cutoff" => $cutoff,
"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" => (isset($urls)?$urls:[])
);
if (count($uri_parts) == 1) { // human readable
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
Mirror URL |
Protocol
| Country |
Completion |
Delay |
Last Sync |
EOF;
print <<
EOF;
$oddity = "odd";
if (isset($content['urls'])) {
foreach ($content['urls'] as $row) {
print " \n";
print " \n";
print " " . $row["url"] . "\n";
print " | \n";
print " \n";
print " " . $row["protocol"] . "\n";
print " | \n";
print " \n";
print " \n";
print " \n";
print " " . $row["country"] . "\n";
print " | \n";
print " \n";
print " " . $row["completion_pct"] . "\n";
print " | \n";
print " \n";
print " " . $row["delay"] . "\n";
print " | \n";
print " \n";
print " " . $row["last_sync"] . "\n";
print " | \n";
print "
\n";
if ($oddity == "odd")
$oddity = "even";
else
$oddity = "odd";
}
}
print <<
EOF;
print <<
EOF;
}
exit( );
} // human readable
if (!export_as_requested(
array(
"json" => $content,
"tsv" => $urls
),
$uri_parts[1]
)) {
throw_http_error(
406,
'Not Acceptable',
implode(
"
\n",
array_merge(
array(
'Unknown output format.',
'Accepted:'
),
array_map(
function($type){
return '' . $type . '';
},
array('json', 'tsv')
)
)
)
);
}
die();
} // status
throw_http_error(501, "Not Implemented");