* allow inbound/outbound in graphs to be swapped (via option in www/func.inc)

This commit is contained in:
Manuel Kasper 2008-12-06 11:19:22 +00:00
parent 07eccf65bb
commit a497c5fc9e
7 changed files with 53 additions and 18 deletions

7
README
View File

@ -1,10 +1,13 @@
AS-Stats v1.1 (2008-09-03)
AS-Stats v1.2 (2008-12-06)
a simple tool to generate per-AS traffic graphs from NetFlow records
by Manuel Kasper, Monzoon Networks AG <mkasper@monzoon.net>
--------------------------------------------------------------------
Changes
-------
v1.2 Allow inbound/outbound in graphs to be swapped (via option
in www/func.inc)
v1.1 Fix for a potential race condition surrounding $childrunning
(reported by Yann Gauteron; experienced on a Linux system)
@ -81,8 +84,6 @@ Installation
ip flow-cache timeout active 5
! enable ip flow ingress on all interfaces listed in your
! "known links" file
int Gi0/x.y
ip flow ingress

View File

@ -5,12 +5,13 @@
* written by Manuel Kasper, Monzoon Networks AG <mkasper@monzoon.net>
*/
$rrdpath = "/var/db/netflow/rrd";
$daystatsfile = "/var/db/netflow/asstats_day.txt";
$rrdpath = "/data/rrd";
$daystatsfile = "/data/asstats_day.txt";
$rrdtool = "/usr/local/bin/rrdtool";
$asinfofile = "asinfo.txt";
$knownlinksfile = "/etc/netflow-knownlinks";
$knownlinksfile = "/data/netflow-knownlinks";
$outispositive = true;
/* note: you might want to put the data from asinfo.txt into an SQL
database to avoid having to read the whole file all the time */

View File

@ -23,7 +23,7 @@ if ($_GET['height'])
$knownlinks = getknownlinks();
$cmd = "$rrdtool graph - " .
"--slope-mode --alt-autoscale --imgformat=PNG --base=1000 --height=$height --width=$width " .
"--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 ";
if ($_GET['nolegend'])
@ -43,14 +43,23 @@ foreach ($knownlinks as $link) {
/* generate a CDEF for each DEF to multiply by 8 (bytes to bits), and reverse for outbound */
foreach ($knownlinks as $link) {
$cmd .= "CDEF:{$link['tag']}_in_bits={$link['tag']}_in,8,* ";
$cmd .= "CDEF:{$link['tag']}_out_bits_rev={$link['tag']}_out,-8,* ";
if ($outispositive) {
$cmd .= "CDEF:{$link['tag']}_in_bits={$link['tag']}_in,-8,* ";
$cmd .= "CDEF:{$link['tag']}_out_bits={$link['tag']}_out,8,* ";
} else {
$cmd .= "CDEF:{$link['tag']}_in_bits={$link['tag']}_in,8,* ";
$cmd .= "CDEF:{$link['tag']}_out_bits={$link['tag']}_out,-8,* ";
}
}
/* generate graph area/stack for inbound */
$i = 0;
foreach ($knownlinks as $link) {
$cmd .= "AREA:{$link['tag']}_in_bits#{$link['color']}:\"{$link['descr']}\"";
if ($outispositive)
$col = $link['color'] . "BB";
else
$col = $link['color'];
$cmd .= "AREA:{$link['tag']}_in_bits#{$col}:\"{$link['descr']}\"";
if ($i > 0)
$cmd .= ":STACK";
$cmd .= " ";
@ -60,7 +69,11 @@ foreach ($knownlinks as $link) {
/* generate graph area/stack for outbound */
$i = 0;
foreach ($knownlinks as $link) {
$cmd .= "AREA:{$link['tag']}_out_bits_rev#{$link['color']}BB:";
if ($outispositive)
$col = $link['color'];
else
$col = $link['color'] . "BB";
$cmd .= "AREA:{$link['tag']}_out_bits#{$col}:";
if ($i > 0)
$cmd .= ":STACK";
$cmd .= " ";

View File

@ -55,7 +55,12 @@ AS: <input type="text" name="as" size="6" />
<?php endif; ?>
<div id="footer">
AS-Stats v1.1 written by Manuel Kasper, Monzoon Networks AG.
AS-Stats v1.2 written by Manuel Kasper, Monzoon Networks AG.<br/>
<?php if ($outispositive): ?>
Outbound traffic: positive / Inbound traffic: negative
<?php else: ?>
Inbound traffic: positive / Outbound traffic: negative
<?php endif; ?>
</div>
</body>

View File

@ -68,7 +68,7 @@ if ($_GET['height'])
$knownlinks = getknownlinks();
$cmd = "$rrdtool graph - " .
"--slope-mode --alt-autoscale --imgformat=PNG --base=1000 --height=$height --width=$width " .
"--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 ";
/* geneate RRD DEFs */
@ -79,8 +79,13 @@ foreach ($topas as $as => $traffic) {
/* generate a CDEF for each DEF to multiply by 8 (bytes to bits), and reverse for outbound */
foreach ($topas as $as => $traffic) {
$cmd .= "CDEF:as{$as}_in_bits=as{$as}_in,8,* ";
$cmd .= "CDEF:as{$as}_out_bits_rev=as{$as}_out,-8,* ";
if ($outispositive) {
$cmd .= "CDEF:as{$as}_in_bits=as{$as}_in,-8,* ";
$cmd .= "CDEF:as{$as}_out_bits=as{$as}_out,8,* ";
} else {
$cmd .= "CDEF:as{$as}_in_bits=as{$as}_in,8,* ";
$cmd .= "CDEF:as{$as}_out_bits=as{$as}_out,-8,* ";
}
}
/* generate graph area/stack for inbound */
@ -99,7 +104,7 @@ foreach ($topas as $as => $traffic) {
/* generate graph area/stack for outbound */
$i = 0;
foreach ($topas as $as => $traffic) {
$cmd .= "AREA:as{$as}_out_bits_rev#{$ascolors[$i]}:";
$cmd .= "AREA:as{$as}_out_bits#{$ascolors[$i]}:";
if ($i > 0)
$cmd .= ":STACK";
$cmd .= " ";

View File

@ -45,7 +45,12 @@ $class = (($i % 2) == 0) ? "even" : "odd";
</table>
<div id="footer">
AS-Stats v1.1 written by Manuel Kasper, Monzoon Networks AG.
AS-Stats v1.2 written by Manuel Kasper, Monzoon Networks AG.<br/>
<?php if ($outispositive): ?>
Outbound traffic: positive / Inbound traffic: negative
<?php else: ?>
Inbound traffic: positive / Outbound traffic: negative
<?php endif; ?>
</div>
</body>

View File

@ -90,7 +90,12 @@ foreach ($knownlinks as $link) {
</div>
<div id="footer">
AS-Stats v1.1 written by Manuel Kasper, Monzoon Networks AG.
AS-Stats v1.2 written by Manuel Kasper, Monzoon Networks AG.<br/>
<?php if ($outispositive): ?>
Outbound traffic: positive / Inbound traffic: negative
<?php else: ?>
Inbound traffic: positive / Outbound traffic: negative
<?php endif; ?>
</div>
</body>