2008-01-16 08:36:45 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-02-19 15:43:28 +00:00
|
|
|
* written by Manuel Kasper, Monzoon Networks AG <mkasper@monzoon.net>
|
2008-01-16 08:36:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('func.inc');
|
|
|
|
|
|
|
|
$as = $_GET['as'];
|
2008-12-18 12:35:42 +00:00
|
|
|
if (!preg_match("/^[0-9a-zA-Z]+$/", $as))
|
2008-01-16 08:36:45 +00:00
|
|
|
die("Invalid AS");
|
|
|
|
|
|
|
|
header("Content-Type: image/png");
|
|
|
|
|
|
|
|
$width = 500;
|
|
|
|
$height = 300;
|
2010-08-02 11:23:42 +00:00
|
|
|
if (isset($_GET['width']))
|
2008-01-16 08:36:45 +00:00
|
|
|
$width = (int)$_GET['width'];
|
2010-08-02 11:23:42 +00:00
|
|
|
if (isset($_GET['height']))
|
2008-01-16 08:36:45 +00:00
|
|
|
$height = (int)$_GET['height'];
|
2013-01-21 15:12:01 +00:00
|
|
|
$v6_el = "";
|
|
|
|
if (@$_GET['v'] == 6)
|
|
|
|
$v6_el = "v6_";
|
2008-01-16 08:36:45 +00:00
|
|
|
|
|
|
|
$knownlinks = getknownlinks();
|
2009-10-10 16:53:25 +00:00
|
|
|
$rrdfile = getRRDFileForAS($as);
|
2008-01-16 08:36:45 +00:00
|
|
|
|
|
|
|
$cmd = "$rrdtool graph - " .
|
2008-12-06 11:19:22 +00:00
|
|
|
"--slope-mode --alt-autoscale -u 0 -l 0 --imgformat=PNG --base=1000 --height=$height --width=$width " .
|
2008-01-16 08:36:45 +00:00
|
|
|
"--color BACK#ffffff00 --color SHADEA#ffffff00 --color SHADEB#ffffff00 ";
|
|
|
|
|
2013-01-21 15:12:01 +00:00
|
|
|
if (@$_GET['v'])
|
|
|
|
$cmd .= "--title IPv" . $_GET['v'] . " ";
|
|
|
|
|
2010-08-02 11:23:42 +00:00
|
|
|
if (isset($_GET['nolegend']))
|
2008-01-16 08:36:45 +00:00
|
|
|
$cmd .= "--no-legend ";
|
|
|
|
|
2010-08-02 11:23:42 +00:00
|
|
|
if (isset($_GET['start']) && is_numeric($_GET['start']))
|
2008-01-16 08:36:45 +00:00
|
|
|
$cmd .= "--start " . $_GET['start'] . " ";
|
|
|
|
|
2010-08-02 11:23:42 +00:00
|
|
|
if (isset($_GET['end']) && is_numeric($_GET['end']))
|
2008-01-16 08:36:45 +00:00
|
|
|
$cmd .= "--end " . $_GET['end'] . " ";
|
|
|
|
|
|
|
|
/* geneate RRD DEFs */
|
|
|
|
foreach ($knownlinks as $link) {
|
2013-01-21 15:12:01 +00:00
|
|
|
$cmd .= "DEF:{$link['tag']}_{$v6_el}in=\"$rrdfile\":{$link['tag']}_{$v6_el}in:AVERAGE ";
|
|
|
|
$cmd .= "DEF:{$link['tag']}_{$v6_el}out=\"$rrdfile\":{$link['tag']}_{$v6_el}out:AVERAGE ";
|
2008-01-16 08:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* generate a CDEF for each DEF to multiply by 8 (bytes to bits), and reverse for outbound */
|
|
|
|
foreach ($knownlinks as $link) {
|
2008-12-06 11:19:22 +00:00
|
|
|
if ($outispositive) {
|
2013-01-21 15:12:01 +00:00
|
|
|
$cmd .= "CDEF:{$link['tag']}_{$v6_el}in_bits={$link['tag']}_{$v6_el}in,-8,* ";
|
|
|
|
$cmd .= "CDEF:{$link['tag']}_{$v6_el}out_bits={$link['tag']}_{$v6_el}out,8,* ";
|
2008-12-06 11:19:22 +00:00
|
|
|
} else {
|
2013-01-21 15:12:01 +00:00
|
|
|
$cmd .= "CDEF:{$link['tag']}_{$v6_el}in_bits={$link['tag']}_{$v6_el}in,8,* ";
|
|
|
|
$cmd .= "CDEF:{$link['tag']}_{$v6_el}out_bits={$link['tag']}_{$v6_el}out,-8,* ";
|
2008-12-06 11:19:22 +00:00
|
|
|
}
|
2008-01-16 08:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* generate graph area/stack for inbound */
|
|
|
|
$i = 0;
|
|
|
|
foreach ($knownlinks as $link) {
|
2008-12-06 11:19:22 +00:00
|
|
|
if ($outispositive)
|
|
|
|
$col = $link['color'] . "BB";
|
|
|
|
else
|
|
|
|
$col = $link['color'];
|
2013-01-21 15:12:01 +00:00
|
|
|
$cmd .= "AREA:{$link['tag']}_{$v6_el}in_bits#{$col}:\"{$link['descr']}\"";
|
2008-01-16 08:36:45 +00:00
|
|
|
if ($i > 0)
|
|
|
|
$cmd .= ":STACK";
|
|
|
|
$cmd .= " ";
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* generate graph area/stack for outbound */
|
|
|
|
$i = 0;
|
|
|
|
foreach ($knownlinks as $link) {
|
2008-12-06 11:19:22 +00:00
|
|
|
if ($outispositive)
|
|
|
|
$col = $link['color'];
|
|
|
|
else
|
|
|
|
$col = $link['color'] . "BB";
|
2013-01-21 15:12:01 +00:00
|
|
|
$cmd .= "AREA:{$link['tag']}_{$v6_el}out_bits#{$col}:";
|
2008-01-16 08:36:45 +00:00
|
|
|
if ($i > 0)
|
|
|
|
$cmd .= ":STACK";
|
|
|
|
$cmd .= " ";
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# zero line
|
|
|
|
$cmd .= "HRULE:0#00000080";
|
|
|
|
|
|
|
|
passthru($cmd);
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
?>
|