IPv6 Top ASN

This commit is contained in:
Francisco José Bernal Fernández 2020-01-06 20:25:00 +01:00 committed by GitHub
parent 02bc0fb0f7
commit b5712e57ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -89,7 +89,7 @@ function getknownlinks() {
return $knownlinks; return $knownlinks;
} }
function getasstats_top($ntop, $statfile, $selected_links, $list_asn = NULL) { function getasstats_top($ntop, $statfile, $selected_links, $list_asn = NULL, $v = NULL) {
try{ try{
$db = new SQLite3($statfile); $db = new SQLite3($statfile);
}catch(Exception $e){ }catch(Exception $e){
@ -104,9 +104,17 @@ function getasstats_top($ntop, $statfile, $selected_links, $list_asn = NULL) {
$query_total = '0'; $query_total = '0';
$query_links = ''; $query_links = '';
foreach($selected_links as $tag){ foreach($selected_links as $tag){
$query_links .= "${tag}_in, ${tag}_out, ${tag}_v6_in, ${tag}_v6_out, "; if ($v == 4 || $v == NULL) {
$query_links .= "${tag}_in, ${tag}_out, ";
} else {
$query_links .= "${tag}_v6_in, ${tag}_v6_out, ";
}
$nlinks += 4; $nlinks += 4;
$query_total .= " + ${tag}_in + ${tag}_out + ${tag}_v6_in + ${tag}_v6_out"; if ($v == 4 || $v == NULL) {
$query_total .= " + ${tag}_in + ${tag}_out";
} else {
$query_total .= " + ${tag}_v6_in + ${tag}_v6_out";
}
} }
if ( $list_asn ) { if ( $list_asn ) {
$where = implode(",", $list_asn); $where = implode(",", $list_asn);

View File

@ -23,7 +23,11 @@ if (@$_GET['numhours'])
$hours = (int)$_GET['numhours']; $hours = (int)$_GET['numhours'];
$statsfile = statsFileForHours($hours); $statsfile = statsFileForHours($hours);
if (@$_GET['v'] == 6) {
$topas = getasstats_top($numtop, $statsfile, array($_GET['link']), $list_asn = NULL, $v=6);
}else {
$topas = getasstats_top($numtop, $statsfile, array($_GET['link'])); $topas = getasstats_top($numtop, $statsfile, array($_GET['link']));
}
/* now make a beautiful graph :) */ /* now make a beautiful graph :) */
header("Content-Type: image/png"); header("Content-Type: image/png");