mirror of
https://github.com/nidebr/as-stats-gui.git
synced 2025-02-20 11:23:18 +08:00
Add old linkusage page (at the request of users)
This commit is contained in:
parent
b57ba64324
commit
902d6263d6
28
func.inc
28
func.inc
@ -277,6 +277,7 @@ function menu($selected_links) {
|
||||
$active_searchas = $dpagename == "history" ? 'class="active"' : "";
|
||||
$active_searchasset = $dpagename == "asset" ? 'class="active"' : "";
|
||||
$active_ix = $dpagename == "ix" ? 'class="active"' : "";
|
||||
$active_linkusage = $dpagename == "linkusage" ? 'class="active"' : "";
|
||||
|
||||
$return = '<header class="main-header">';
|
||||
$return .= '<nav class="navbar navbar-static-top">';
|
||||
@ -308,6 +309,20 @@ function menu($selected_links) {
|
||||
$return .='<li '.$active_searchas.'><a href="history.php">View AS</a></li>';
|
||||
$return .='<li '.$active_searchasset.'><a href="asset.php">View AS-SET</a></li>';
|
||||
$return .='<li '.$active_ix.'><a href="ix.php">View IX Stats</a></li>';
|
||||
//$return .='<li '.$active_linkusage.'><a href="linkusage.php">Link Usage</a></li>';
|
||||
|
||||
if ( count($top_intervals) < 2 ) {
|
||||
$return .= '<li '.$active_linkusage.'><a href="linkusage.php">Link Usage</a></li>';
|
||||
} else {
|
||||
$return .= '<li class="dropdown '.$active_linkusage.'">';
|
||||
$return .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Link Usage <span class="caret"></span></a>';
|
||||
$return .= '<ul class="dropdown-menu" role="menu">';
|
||||
foreach ($top_intervals as $interval) {
|
||||
$return .= '<li><a href="linkusage.php?numhours=' . $interval['hours'] . '">Link Usage - ' . $interval['label'] . '</a></li>';
|
||||
}
|
||||
$return .= '</ul>';
|
||||
$return .= '</li>';
|
||||
}
|
||||
|
||||
$return .='</ul>';
|
||||
|
||||
@ -379,4 +394,17 @@ function content_header($titre, $small) {
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
function box_linkusage ($title, $img) {
|
||||
$return = '<div class="box box-primary">';
|
||||
$return .= '<div class="box-header with-border">';
|
||||
$return .= '<i class="fa fa-bar-chart-o"></i>';
|
||||
$return .= '<h3 class="box-title">'.$title.'</h3>';
|
||||
$return .= '</div>';
|
||||
$return .= '<div class="box-body">';
|
||||
$return .= '<center>'.$img.'</center>';
|
||||
$return .= '</div>';
|
||||
$return .= '</div>';
|
||||
return $return;
|
||||
}
|
||||
?>
|
||||
|
@ -20,13 +20,13 @@ if ( isset($_GET['as']) ) {
|
||||
$rrdfile = getRRDFileForAS($as, $peerusage);
|
||||
|
||||
$daily_graph_v4 = getHTMLImg($as, 4, $asinfo['descr'], time() - 24 * 3600, time(), $peerusage, 'daily graph', 'detailgraph', true);
|
||||
$weekly_graph_v4 = getHTMLImg($as, 4, $asinfo['descr'], time() - 7 * 86400, time(), $peerusage, 'weekly graph', 'detailgraph', true);
|
||||
$weekly_graph_v4 = getHTMLImg($as, 4, $asinfo['descr'], time() - 6.9 * 86400, time(), $peerusage, 'weekly graph', 'detailgraph', true);
|
||||
$monthly_graph_v4 = getHTMLImg($as, 4, $asinfo['descr'], time() - 30 * 86400, time(), $peerusage, 'monthly graph', 'detailgraph', true);
|
||||
$yearly_graph_v4 = getHTMLImg($as, 4, $asinfo['descr'], time() - 365 * 86400, time(), $peerusage, 'yearly graph', 'detailgraph', true);
|
||||
|
||||
if ($showv6) {
|
||||
$daily_graph_v6 = getHTMLImg($as, 6, $asinfo['descr'], time() - 24 * 3600, time(), $peerusage, 'daily graph', 'detailgraph', true);
|
||||
$weekly_graph_v6 = getHTMLImg($as, 6, $asinfo['descr'], time() - 7 * 86400, time(), $peerusage, 'weekly graph', 'detailgraph', true);
|
||||
$weekly_graph_v6 = getHTMLImg($as, 6, $asinfo['descr'], time() - 6.9 * 86400, time(), $peerusage, 'weekly graph', 'detailgraph', true);
|
||||
$monthly_graph_v6 = getHTMLImg($as, 6, $asinfo['descr'], time() - 30 * 86400, time(), $peerusage, 'monthly graph', 'detailgraph', true);
|
||||
$yearly_graph_v6 = getHTMLImg($as, 6, $asinfo['descr'], time() - 365 * 86400, time(), $peerusage, 'yearly graph', 'detailgraph', true);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ if ($peerusage) {
|
||||
|
||||
$label = statsLabelForHours($hours);
|
||||
$knownlinks = getknownlinks();
|
||||
|
||||
$selected_links = array();
|
||||
|
||||
foreach($knownlinks as $link){
|
||||
@ -185,9 +186,7 @@ if ( !$detect->isMobile() && !$detect->isTablet() ) {
|
||||
<?php echo content_header('Top ' . $ntop . ' AS', '('.$label.')'); ?>
|
||||
|
||||
<section class="content">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12 col-lg-<?php echo $first_col; ?>">
|
||||
<div class="row">
|
||||
|
||||
@ -270,6 +269,7 @@ if ( !$detect->isMobile() && !$detect->isTablet() ) {
|
||||
<script src="bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
||||
<script src="plugins/fastclick/fastclick.min.js"></script>
|
||||
<script src="plugins/jQueryUI/jquery-ui.min.js"></script>
|
||||
<script src="dist/js/app.min.js"></script>
|
||||
|
||||
</body>
|
||||
|
111
linkgraph.php
Normal file
111
linkgraph.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* written by Manuel Kasper <mk@neon1.net> for Monzoon Networks AG
|
||||
*/
|
||||
|
||||
require_once('func.inc');
|
||||
|
||||
$numtop = 10;
|
||||
$ascolors = array("A6CEE3", "1F78B4", "B2DF8A", "33A02C", "FB9A99", "E31A1C", "FDBF6F", "FF7F00", "CAB2D6", "6A3D9A");
|
||||
|
||||
$link = $_GET['link'];
|
||||
if (!preg_match("/^[0-9a-zA-Z][0-9a-zA-Z\-_]+$/", $link))
|
||||
die("Invalid link");
|
||||
|
||||
$v6_el = "";
|
||||
if (@$_GET['v'] == 6)
|
||||
$v6_el = "v6_";
|
||||
|
||||
$hours = 24;
|
||||
if (@$_GET['numhours'])
|
||||
$hours = (int)$_GET['numhours'];
|
||||
|
||||
$statsfile = statsFileForHours($hours);
|
||||
$topas = getasstats_top($numtop, $statsfile, array($_GET['link']));
|
||||
|
||||
/* now make a beautiful graph :) */
|
||||
header("Content-Type: image/png");
|
||||
|
||||
$width = $default_graph_width;
|
||||
$height = $default_graph_height;
|
||||
if (@$_GET['width'])
|
||||
$width = (int)$_GET['width'];
|
||||
if (@$_GET['height'])
|
||||
$height = (int)$_GET['height'];
|
||||
|
||||
$knownlinks = getknownlinks();
|
||||
|
||||
if ($compat_rrdtool12) {
|
||||
/* cannot use full-size-mode - must estimate height/width */
|
||||
$height -= 205;
|
||||
$width -= 81;
|
||||
}
|
||||
|
||||
$start = time() - $hours*3600;
|
||||
$end = time();
|
||||
|
||||
$cmd = "$rrdtool graph - " .
|
||||
"--slope-mode --alt-autoscale -u 0 -l 0 --imgformat=PNG --base=1000 --height=$height --width=$width " .
|
||||
"--color BACK#ffffff00 --color SHADEA#ffffff00 --color SHADEB#ffffff00 " .
|
||||
"--start " . $start . " --end " . $end . " ";
|
||||
|
||||
if (!$compat_rrdtool12)
|
||||
$cmd .= "--full-size-mode ";
|
||||
|
||||
if($showtitledetail && @$_GET['dname'] != "")
|
||||
$cmd .= "--title " . escapeshellarg($_GET['dname']) . " ";
|
||||
else
|
||||
if (isset($_GET['v']) && is_numeric($_GET['v']))
|
||||
$cmd .= "--title IPv" . $_GET['v'] . " ";
|
||||
|
||||
/* geneate RRD DEFs */
|
||||
foreach ($topas as $as => $traffic) {
|
||||
$rrdfile = getRRDFileForAS($as);
|
||||
$cmd .= "DEF:as{$as}_{$v6_el}in=\"$rrdfile\":{$link}_{$v6_el}in:AVERAGE ";
|
||||
$cmd .= "DEF:as{$as}_{$v6_el}out=\"$rrdfile\":{$link}_{$v6_el}out:AVERAGE ";
|
||||
}
|
||||
|
||||
/* generate a CDEF for each DEF to multiply by 8 (bytes to bits), and reverse for outbound */
|
||||
foreach ($topas as $as => $traffic) {
|
||||
if ($outispositive) {
|
||||
$cmd .= "CDEF:as{$as}_{$v6_el}in_bits=as{$as}_{$v6_el}in,-8,* ";
|
||||
$cmd .= "CDEF:as{$as}_{$v6_el}out_bits=as{$as}_{$v6_el}out,8,* ";
|
||||
} else {
|
||||
$cmd .= "CDEF:as{$as}_{$v6_el}in_bits=as{$as}_{$v6_el}in,8,* ";
|
||||
$cmd .= "CDEF:as{$as}_{$v6_el}out_bits=as{$as}_{$v6_el}out,-8,* ";
|
||||
}
|
||||
}
|
||||
|
||||
/* generate graph area/stack for inbound */
|
||||
$i = 0;
|
||||
foreach ($topas as $as => $traffic) {
|
||||
$asinfo = getASInfo($as);
|
||||
$descr = str_replace(":", "\\:", utf8_decode($asinfo['descr']));
|
||||
|
||||
$cmd .= "AREA:as{$as}_{$v6_el}in_bits#{$ascolors[$i]}:\"AS{$as} ({$descr})\\n\"";
|
||||
if ($i > 0)
|
||||
$cmd .= ":STACK";
|
||||
$cmd .= " ";
|
||||
$i++;
|
||||
}
|
||||
|
||||
/* generate graph area/stack for outbound */
|
||||
$i = 0;
|
||||
foreach ($topas as $as => $traffic) {
|
||||
$cmd .= "AREA:as{$as}_{$v6_el}out_bits#{$ascolors[$i]}:";
|
||||
if ($i > 0)
|
||||
$cmd .= ":STACK";
|
||||
$cmd .= " ";
|
||||
$i++;
|
||||
}
|
||||
|
||||
# zero line
|
||||
$cmd .= "HRULE:0#00000080";
|
||||
|
||||
passthru($cmd);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
101
linkusage.php
Normal file
101
linkusage.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php include("func.inc"); ?>
|
||||
|
||||
<?php
|
||||
$knownlinks = getknownlinks();
|
||||
$hours = 24;
|
||||
if (@$_GET['numhours'])
|
||||
$hours = (int)$_GET['numhours'];
|
||||
$label = statsLabelForHours($hours);
|
||||
$i = 0;
|
||||
foreach ($knownlinks as $link) {
|
||||
$class = (($i % 2) == 0) ? "" : "even";
|
||||
if ($showv6) {
|
||||
$list_img[$link['tag']] = '<img alt="link graph" src="linkgraph.php?link='.$link['tag'].'&numhours='.$hours.'&width='.$linkusage_graph_width.'&height='.$linkusage_graph_height.'&dname='.rawurlencode($link['descr'] . " - IPv4").'" width="'.$linkusage_graph_width.'" height="'.$linkusage_graph_height.'" border="0" />';
|
||||
$list_img_v6[$link['tag']] = '<img alt="link graph" src="linkgraph.php?link='.$link['tag'].'&numhours='.$hours.'&width='.$linkusage_graph_width.'&height='.$linkusage_graph_height.'&dname='.rawurlencode($link['descr'] . " - IPv6").'&v=6" width="'.$linkusage_graph_width.'" height="'.$linkusage_graph_height.'" border="0" />';
|
||||
} else {
|
||||
$list_img[$link['tag']] = '<img alt="link graph" src="linkgraph.php?link='.$link['tag'].'&numhours='.$hours.'&width='.$linkusage_graph_width.'&height='.$linkusage_graph_height.'&dname='.rawurlencode($link['descr']).'" width="'.$linkusage_graph_width.'" height="'.$linkusage_graph_height.'" border="0" />';
|
||||
}
|
||||
if ( ($showtitledetail && !$hidelinkusagename) || (!$showtitledetail) ) {
|
||||
$txt_title[$link['tag']] = $link['descr'];
|
||||
} else { $txt_title = ""; }
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta http-equiv="Refresh" content="300">
|
||||
<title>AS-Stats | Link Usage - Top 10 AS per link</title>
|
||||
<link rel="icon" href="favicon.ico" />
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="plugins/font-awesome/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="plugins/ionicons/ionicons.min.css">
|
||||
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
|
||||
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
|
||||
<link rel="stylesheet" href="css/custom.css">
|
||||
</head>
|
||||
<body class="hold-transition skin-black-light sidebar-collapse layout-top-nav fixed">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<!-- =============================================== -->
|
||||
<?php echo menu($selected_links); ?>
|
||||
<!-- =============================================== -->
|
||||
|
||||
<div class="content-wrapper">
|
||||
<?php echo content_header('Top 10 AS - per link usage', '(' . $label . ')'); ?>
|
||||
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<?php
|
||||
if ( !$txt_title ) {
|
||||
if (!$showv6) {
|
||||
foreach ($list_img as $key => $img) {
|
||||
echo '<div class="col-lg-6">';
|
||||
echo box_linkusage('Link Usage', $img);
|
||||
echo '</div>';
|
||||
}
|
||||
} else {
|
||||
foreach ($list_img as $key => $img) {
|
||||
echo '<div class="col-lg-12">';
|
||||
echo box_linkusage('Link Usage', $img . ' ' . $list_img_v6[$key]);
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!$showv6) {
|
||||
foreach ($list_img as $key => $img) {
|
||||
echo '<div class="col-lg-6">';
|
||||
echo box_linkusage('Link Usage for ' . $txt_title[$key], $img);
|
||||
echo '</div>';
|
||||
}
|
||||
} else {
|
||||
foreach ($list_img as $key => $img) {
|
||||
echo '<div class="col-lg-12">';
|
||||
echo box_linkusage('Link Usage for ' . $txt_title[$key], $img . ' ' . $list_img_v6[$key]);
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- =============================================== -->
|
||||
<?php echo footer(); ?>
|
||||
<!-- =============================================== -->
|
||||
|
||||
</div>
|
||||
|
||||
<script src="plugins/jQuery/jquery-2.2.3.min.js"></script>
|
||||
<script src="bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
||||
<script src="plugins/fastclick/fastclick.min.js"></script>
|
||||
<script src="plugins/jQueryUI/jquery-ui.min.js"></script>
|
||||
<script src="dist/js/app.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user