mirror of
https://github.com/manuelkasper/AS-Stats.git
synced 2025-02-20 11:44:12 +08:00
commit
d3b5adfd48
@ -7,6 +7,7 @@
|
||||
|
||||
use strict;
|
||||
use 5.010;
|
||||
use Socket qw(AF_INET6 inet_pton inet_ntop);
|
||||
use IO::Select;
|
||||
use IO::Socket;
|
||||
use RRDs;
|
||||
@ -77,7 +78,7 @@ if ($sflow_server_port == $server_port) {
|
||||
}
|
||||
|
||||
my %myas;
|
||||
if($sflow_server_port > 0){
|
||||
if($sflow_server_port > 0 || defined($myas_opt)){
|
||||
die('No ASN found, please specify -a') if !defined($myas_opt);
|
||||
%myas = map {$_ => 1 } split(',', $myas_opt);
|
||||
for my $i (%myas){
|
||||
@ -306,6 +307,7 @@ sub parse_netflow_v9_data_flowset {
|
||||
while (($ofs + $len) <= $datalen) {
|
||||
# Interpret values according to template
|
||||
my ($inoctets, $outoctets, $srcas, $dstas, $snmpin, $snmpout, $ipversion, $vlanin, $vlanout);
|
||||
my ($srcip, $dstip);
|
||||
|
||||
$inoctets = 0;
|
||||
$outoctets = 0;
|
||||
@ -356,7 +358,11 @@ sub parse_netflow_v9_data_flowset {
|
||||
}
|
||||
} elsif ($cur_fldtype == 60) { # IP_PROTOCOL_VERSION
|
||||
$ipversion = unpack("C", $cur_fldval);
|
||||
} elsif ($cur_fldtype == 27 || $cur_fldtype == 28) { # IPV6_SRC_ADDR/IPV6_DST_ADDR
|
||||
} elsif ($cur_fldtype == 27) { # IPV6_SRC_ADDR
|
||||
$srcip = inet_ntop(AF_INET6, $cur_fldval);
|
||||
$ipversion = 6;
|
||||
} elsif ($cur_fldtype == 28) { # IPV6_DST_ADDR
|
||||
$dstip = inet_ntop(AF_INET6, $cur_fldval);
|
||||
$ipversion = 6;
|
||||
} elsif ($cur_fldtype == 58) { # SRC_VLAN
|
||||
$vlanin = unpack("n", $cur_fldval);
|
||||
@ -365,7 +371,16 @@ sub parse_netflow_v9_data_flowset {
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($srcas) && defined($dstas) && defined($snmpin) && defined($snmpout)) {
|
||||
if (defined($snmpin) && defined($snmpout)) {
|
||||
if (not (defined($srcas))) { $srcas=0; }
|
||||
if (not (defined($dstas))) { $dstas=0; }
|
||||
if ($srcas == 0 && $dstas == 0 && $ipversion == 6 && defined($srcip) && defined($dstip)) {
|
||||
$srcas = replace_asn($srcip, $srcas);
|
||||
$dstas = replace_asn($dstip, $dstas);
|
||||
# substitute 0 for own AS number
|
||||
if ($myas{$srcas}) { $srcas = 0; }
|
||||
if ($myas{$dstas}) { $dstas = 0; }
|
||||
}
|
||||
handleflow($ipaddr, $inoctets + $outoctets, $srcas, $dstas, $snmpin, $snmpout, $ipversion, 'netflow', $vlanin, $vlanout);
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,11 @@ function getHTMLImg($as, $ipversion, $desc, $start, $end, $peerusage, $alt, $cla
|
||||
global $top_graph_width;
|
||||
global $top_graph_height;
|
||||
|
||||
$dname = rawurlencode("AS$as - $desc - IPV$ipversion");
|
||||
$ipvstring = "$ipversion";
|
||||
if($ipversion == 0 || $ipversion == 46 || $ipversion == 64)
|
||||
$ipvstring = "4+IPv6";
|
||||
|
||||
$dname = rawurlencode("AS$as - $desc - IPv$ipvstring");
|
||||
|
||||
$result = "<img alt='$alt' class='$class' src='gengraph.php?v=$ipversion&as=$as&peerusage=$peerusage&dname=$dname&start=$start&end=$end";
|
||||
if(!$history)
|
||||
|
@ -22,7 +22,12 @@ if (isset($_GET['height']))
|
||||
$v6_el = "";
|
||||
if (@$_GET['v'] == 6)
|
||||
$v6_el = "v6_";
|
||||
|
||||
$mixv4v6 = false;
|
||||
$versionstring = @$_GET['v'];
|
||||
if (@$_GET['v'] == 0 || @$_GET['v'] == 10 || @$_GET['v'] == 46 || @$_GET['v'] == 64) {
|
||||
$mixv4v6 = true;
|
||||
$versionstring = '4 + IPv6';
|
||||
}
|
||||
if(isset($_GET['peerusage']) && $_GET['peerusage'] == '1')
|
||||
$peerusage = 1;
|
||||
else
|
||||
@ -46,6 +51,18 @@ if(isset($_GET['selected_links'])){
|
||||
$knownlinks = $links;
|
||||
}
|
||||
|
||||
if ($mixv4v6) {
|
||||
$v6links = array();
|
||||
foreach ($knownlinks as $v4link) {
|
||||
$tag6 = $v4link['tag']."_v6";
|
||||
$link = array('tag' => $tag6,
|
||||
'color' => $v4link['color'],
|
||||
'descr' => $v4link['descr']);
|
||||
$v6links[] = $link;
|
||||
}
|
||||
$knownlinks = array_merge($knownlinks, $v6links);
|
||||
}
|
||||
|
||||
$rrdfile = getRRDFileForAS($as, $peerusage);
|
||||
|
||||
if ($compat_rrdtool12) {
|
||||
@ -74,7 +91,7 @@ if($showtitledetail && @$_GET['dname'] != "")
|
||||
$cmd .= "--title " . escapeshellarg($_GET['dname']) . " ";
|
||||
else
|
||||
if (isset($_GET['v']) && is_numeric($_GET['v']))
|
||||
$cmd .= "--title IPv" . $_GET['v'] . " ";
|
||||
$cmd .= "--title IPv" . $versionstring . " ";
|
||||
|
||||
if (isset($_GET['nolegend']))
|
||||
$cmd .= "--no-legend ";
|
||||
|
19
www/top.php
19
www/top.php
@ -19,6 +19,12 @@ $hours = 24;
|
||||
if (@$_GET['numhours'])
|
||||
$hours = (int)$_GET['numhours'];
|
||||
|
||||
$mixv4v6 = false;
|
||||
if (isset($_GET['mixv4v6'])) {
|
||||
$mixv4v6 = $_GET['mixv4v6'];
|
||||
$showv6 = false;
|
||||
}
|
||||
|
||||
if ($peerusage)
|
||||
$statsfile = $daypeerstatsfile;
|
||||
else {
|
||||
@ -82,10 +88,14 @@ $class = (($i % 2) == 0) ? "even" : "odd";
|
||||
</div>
|
||||
<div class="small">IPv4: ~ <?php echo format_bytes($nbytes[0]); ?> in /
|
||||
<?php echo format_bytes($nbytes[1]); ?> out in the last <?php echo $label?></div>
|
||||
<?php if ($showv6): ?>
|
||||
<?php if ($showv6 || $mixv4v6): ?>
|
||||
<div class="small">IPv6: ~ <?php echo format_bytes($nbytes[2]); ?> in /
|
||||
<?php echo format_bytes($nbytes[3]); ?> out in the last <?php echo $label?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($mixv4v6): ?>
|
||||
<div class="small">Total: ~ <?php echo format_bytes($nbytes[0]+$nbytes[2]); ?> in /
|
||||
<?php echo format_bytes($nbytes[1]+$nbytes[3]); ?> out in the last <?php echo $label?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($customlinks)): ?>
|
||||
<div class="customlinks">
|
||||
@ -106,7 +116,11 @@ echo join(" | ", $htmllinks);
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
echo getHTMLUrl($as, 4, $asinfo['descr'], $start, $end, $peerusage, $selected_links);
|
||||
if ($mixv4v6) {
|
||||
echo getHTMLUrl($as, 0, $asinfo['descr'], $start, $end, $peerusage, $selected_links);
|
||||
} else {
|
||||
echo getHTMLUrl($as, 4, $asinfo['descr'], $start, $end, $peerusage, $selected_links);
|
||||
}
|
||||
if ($showv6)
|
||||
echo getHTMLUrl($as, 6, $asinfo['descr'], $start, $end, $peerusage, $selected_links);
|
||||
?>
|
||||
@ -120,6 +134,7 @@ echo join(" | ", $htmllinks);
|
||||
<form method='get'>
|
||||
<input type='hidden' name='numhours' value='<?php echo $hours; ?>'/>
|
||||
<input type='hidden' name='n' value='<?php echo $ntop; ?>'/>
|
||||
<input type="checkbox" name="mixv4v6" value="true" <?php if($mixv4v6) echo 'checked'; ?>>Add v4+v6</input>
|
||||
<table>
|
||||
<?php
|
||||
$knownlinks = getknownlinks();
|
||||
|
Loading…
x
Reference in New Issue
Block a user