Merge pull request #22

manually fixed merge conflict
This commit is contained in:
Manuel Kasper 2014-03-12 13:45:30 +01:00
parent f3eb7618f0
commit 2cb4585ea1
15 changed files with 425 additions and 33 deletions

View File

@ -20,7 +20,7 @@ start() {
echo -n $"Starting $prog: "
# start daemon
daemon /data/as-stats/bin/$DAEMON $RRDDIR $KNOWNLINKS >> /data/as-stats/output.log &
daemon /data/as-stats/bin/$DAEMON -r $RRDDIR -k $KNOWNLINKS -p 9000 -a 0 -P 0 >> /data/as-stats/output.log &
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/as-stats
@ -77,4 +77,3 @@ case "$1" in
esac
exit $RETVAL

3
disableSeLinux.sh Normal file
View File

@ -0,0 +1,3 @@
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
yum update y
reboot

50
installAS-Stats.sh Normal file
View File

@ -0,0 +1,50 @@
yum install -y httpd httpd-devel php php-gd phpimap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mcrypt curl curl-devel perl-libwwwperl libxml2 php-mbstring rrdtool perl-rrdtool
yum install -y jwhois
service iptables stop
service iptables status
chkconfig iptables off
mkdir /data
cd /data
git clone git://github.com/datatecuk/AS-Stats
mv /data/AS-Stats/ /data/as-stats
mkdir /data/as-stats/rrd
chmod 0777 /data/as-stats/rrd
mkdir /data/as-stats/www/asset
chmod 0777 /data/as-stats/www/asset
cp /data/as-stats/contrib/centos/as-stats /etc/rc.d/init.d/as-stats
chmod 0755 /etc/rc.d/init.d/as-stats
chmod 0777 /data/as-stats/bin/asstatd.pl
chmod 0777 /data/as-stats/bin/rrd-extractstats.pl
cp /data/as-stats/tools/add_ds.sh /data/as-stats/rrd/add_ds.sh
chmod 0777 /data/as-stats/rrd/add_ds.sh
echo "Alias /as-stats /data/as-stats/www
<Directory /data/as-stats/www/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order allow,deny
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
" > /etc/httpd/conf.d/as-stats.conf
echo "<html>
<head>
<meta http-equiv=\"REFRESH\" content=\"0;URL=/as-stats/\">
</head>
<body>
</body>
</html>
" > /var/www/html/index.html
echo "*/5 * * * * root perl /data/as-stats/bin/rrd-extractstats.pl /data/as-stats/rrd /data/as-stats/conf/knownlinks /data/as-stats/asstats_day.txt > /dev/null 2>&1
" > /etc/cron.d/as-stats
chkconfig httpd on
service httpd start
chkconfig as-stats on
service as-stats start

View File

@ -11,7 +11,7 @@ for i in $A ; do
for f in *.rrd; do
echo "file: $f"
mv $f $f.old
rrdtool dump $f.old | /path/to/add_ds_proc.pl | rrdtool restore - $f.new
rrdtool dump $f.old | /data/as-stats/tools/add_ds_proc.pl | rrdtool restore - $f.new
mv $f.new $f
rm -f $f.old
done

View File

@ -35,10 +35,23 @@ if ( $action == "clearall" ) {
</head>
<body onload="document.forms[0].asset.focus(); document.forms[0].asset.select();">
<div id="nav"><a href="top.php">Top AS</a> | <a href="history.php">View an AS</a> | View an AS-SET | <a href="linkusage.php">Link usage</a></div>
<div id="nav"><?php include('headermenu.inc'); ?></div>
<?php if ($asset): ?>
<div class="pgtitle">History for AS-SET: <?php echo $asset; ?></div>
<div class="pgtitle">History for AS-SET: <?php echo $asset; ?>
<?php if (!empty($customlinks)): ?>
<div class="customlinks">
<?php
$htmllinks = array();
foreach ($customlinks as $linkname => $url) {
$url = str_replace("%as%", $as, $url);
$htmllinks[] = "<a href=\"$url\" target=\"_blank\">" . htmlspecialchars($linkname) . "</a>\n";
}
echo join(" | ", $htmllinks);
?>
</div>
<?php endif; ?>
</div>
<?php else: ?>
<div class="pgtitle">View history for an AS-SET</div>
<?php endif; ?>
@ -107,7 +120,12 @@ if ( $action == "clearall" ) {
$rrdfile = getRRDFileForAS($as);
if (file_exists($rrdfile)): ?>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;nolegend=1" width="581" height="204" border="0" /></a>
<?php if ($showv6): ?>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=4&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" width="581" height="204" border="0" /></a>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=6&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" width="581" height="204" border="0" /></a>
<?php else: ?>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=4&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" width="581" height="204" border="0" /></a>
<?php endif; ?>
<?php else: ?>
<p><center>No data found for AS<?php echo $as; ?></center></p>
<?php endif; ?>

View File

@ -13,6 +13,8 @@ $show95th = true;
$ntop = 20;
$showv6 = true;
$showtitledetail = true;
$hidelinkusagename = true; # $showtitledetail will need to be true to allow this
$whois = "/usr/bin/whois";
$assetpath = "asset";

View File

@ -35,8 +35,11 @@ if($outispositive)
else
$cmd .= "--vertical-label '<- OUT | IN ->' ";
if (isset($_GET['v']) && is_numeric($_GET['v']))
$cmd .= "--title IPv" . $_GET['v'] . " ";
if($showtitledetail && $_GET['dname'] != "")
$cmd .= "--title " . str_replace(' ','\ ',rawurldecode($_GET['dname'])) . " ";
else
if (isset($_GET['v']) && is_numeric($_GET['v']))
$cmd .= "--title IPv" . $_GET['v'] . " ";
if (isset($_GET['nolegend']))
$cmd .= "--no-legend ";

45
www/headermenu.inc Normal file
View File

@ -0,0 +1,45 @@
<?php
$dpagename = basename($_SERVER['PHP_SELF'], ".php");
if ($dpagename == "top"):
?><a href="top.php" class="selected">Top AS</a> | <?php
else:
?><a href="top.php">Top AS</a> | <?php
endif;
if ($dpagename == "top4"):
?><a href="top4.php" class="selected">4 Hour</a> | <?php
else:
?><a href="top4.php">4 Hour</a> | <?php
endif;
if ($dpagename == "top12"):
?><a href="top12.php" class="selected">12 Hour</a> | <?php
else:
?><a href="top12.php">12 Hour</a> | <?php
endif;
if ($dpagename == "history"):
?><a href="history.php" class="selected">View an AS</a> | <?php
else:
?><a href="history.php">View an AS</a> | <?php
endif;
if ($dpagename == "asset"):
?><a href="asset.php" class="selected">View an AS-SET</a> | <?php
else:
?><a href="asset.php">View an AS-SET</a> | <?php
endif;
if ($dpagename == "linkusage"):
?><a href="linkusage.php" class="selected">Link usage</a><?php
else:
?><a href="linkusage.php">Link usage</a><?php
endif;
?>

View File

@ -28,44 +28,65 @@ $rrdfile = getRRDFileForAS($as);
<body onload="document.forms[0].as.focus(); document.forms[0].as.select();">
<div id="nav"><a href="top.php">Top AS</a> | View an AS | <a href="asset.php">View an AS-SET</a> | <a href="linkusage.php">Link usage</a></div>
<div id="nav"><?php include('headermenu.inc'); ?></div>
<?php if ($as): ?>
<div class="pgtitle">History for AS<?php echo $as; ?>: <?php echo $asinfo['descr']; ?></div>
<div class="pgtitle">History for AS<?php echo $as; ?>: <?php echo $asinfo['descr']; ?>
<?php if (!empty($customlinks)): ?>
<div class="customlinks">
<?php
$htmllinks = array();
foreach ($customlinks as $linkname => $url) {
$url = str_replace("%as%", $as, $url);
$htmllinks[] = "<a href=\"$url\" target=\"_blank\">" . htmlspecialchars($linkname) . "</a>\n";
}
echo join(" | ", $htmllinks);
?>
</div>
<?php endif; ?>
</div>
<?php if (!file_exists($rrdfile)): ?>
<p>No data found for AS <?php echo $as; ?></p>
<?php else: ?>
<div class="title">4 Hourly</div>
<?php if ($showv6): ?>
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 4*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" alt="weekly graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 4*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" alt="weekly graph" />
<?php else: ?>
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;start=<?php echo (time() - 4*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" alt="weekly graph" />
<?php endif; ?>
<div class="title">Daily</div>
<?php if ($showv6): ?>
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>" alt="daily graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>" alt="daily graph" />
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" alt="daily graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" alt="daily graph" />
<?php else: ?>
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>" alt="daily graph" />
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" alt="daily graph" />
<?php endif; ?>
<div class="title">Weekly</div>
<?php if ($showv6): ?>
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 7*86400);?>&amp;end=<?php echo time(); ?>" alt="weekly graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 7*86400);?>&amp;end=<?php echo time(); ?>" alt="weekly graph" />
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 7*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" alt="weekly graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 7*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" alt="weekly graph" />
<?php else: ?>
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;start=<?php echo (time() - 7*86400);?>&amp;end=<?php echo time(); ?>" alt="weekly graph" />
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;start=<?php echo (time() - 7*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" alt="weekly graph" />
<?php endif; ?>
<div class="title">Monthly</div>
<?php if ($showv6): ?>
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 30*86400);?>&amp;end=<?php echo time(); ?>" alt="monthly graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 30*86400);?>&amp;end=<?php echo time(); ?>" alt="monthly graph" />
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 30*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" alt="monthly graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 30*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" alt="monthly graph" />
<?php else: ?>
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;start=<?php echo (time() - 30*86400);?>&amp;end=<?php echo time(); ?>" alt="monthly graph" />
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;start=<?php echo (time() - 30*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" alt="monthly graph" />
<?php endif; ?>
<div class="title">Yearly</div>
<?php if ($showv6): ?>
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 365*86400);?>&amp;end=<?php echo time(); ?>" alt="yearly graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 365*86400);?>&amp;end=<?php echo time(); ?>" alt="yearly graph" />
<img class="detailgraph" src="gengraph.php?v=4&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 365*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" alt="yearly graph" />
<img class="detailgraph2" src="gengraph.php?v=6&amp;as=<?php echo $as; ?>&amp;start=<?php echo (time() - 365*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" alt="yearly graph" />
<?php else: ?>
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;start=<?php echo (time() - 365*86400);?>&amp;end=<?php echo time(); ?>" alt="yearly graph" />
<img class="detailgraph" src="gengraph.php?as=<?php echo $as; ?>&amp;start=<?php echo (time() - 365*86400);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" alt="yearly graph" />
<?php endif; ?>
<?php endif; ?>
<?php else: ?>

View File

@ -71,8 +71,11 @@ $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 ";
if (isset($_GET['v']) && is_numeric($_GET['v']))
$cmd .= "--title IPv" . $_GET['v'] . " ";
if($showtitledetail && $_GET['dname'] != "")
$cmd .= "--title " . str_replace(' ','\ ',rawurldecode($_GET['dname'])) . " ";
else
if (isset($_GET['v']) && is_numeric($_GET['v']))
$cmd .= "--title IPv" . $_GET['v'] . " ";
/* geneate RRD DEFs */
foreach ($topas as $as => $traffic) {

View File

@ -22,7 +22,7 @@ $knownlinks = getknownlinks();
<body>
<div id="nav"><a href="top.php">Top AS</a> | <a href="history.php">View an AS</a> | <a href="asset.php">View an AS-SET</a> | Link usage</div>
<div id="nav"><?php include('headermenu.inc'); ?></div>
<div class="pgtitle">Link usage - top 10 AS per link</div>
<table class="astable">
@ -31,17 +31,19 @@ $knownlinks = getknownlinks();
$class = (($i % 2) == 0) ? "even" : "odd";
?>
<tr class="<?php echo $class; ?>">
<?php if (($showtitledetail && !$hidelinkusagename) || (!$showtitledetail)): ?>
<th style="width: 15em">
<div class="title">
<?php echo $link['descr']; ?>
</div>
</th>
<?php endif; ?>
<td>
<?php if ($showv6): ?>
<img alt="link graph" src="linkgraph.php?link=<?php echo $link['tag']; ?>&amp;width=500&amp;height=300&amp;v=4" width="581" height="499" border="0" />
<img alt="link graph" src="linkgraph.php?link=<?php echo $link['tag']; ?>&amp;width=500&amp;height=300&amp;v=6" width="581" height="499" border="0" />
<img alt="link graph" src="linkgraph.php?link=<?php echo $link['tag']; ?>&amp;width=500&amp;height=300&amp;v=4&amp;dname=<?php echo rawurlencode($link['descr'] . " - IPV4"); ?>" width="581" height="499" border="0" />
<img alt="link graph" src="linkgraph.php?link=<?php echo $link['tag']; ?>&amp;width=500&amp;height=300&amp;v=6&amp;dname=<?php echo rawurlencode($link['descr'] . " - IPV4"); ?>" width="581" height="499" border="0" />
<?php else: ?>
<img alt="link graph" src="linkgraph.php?link=<?php echo $link['tag']; ?>&amp;width=500&amp;height=300" width="581" height="481" border="0" />
<img alt="link graph" src="linkgraph.php?link=<?php echo $link['tag']; ?>&amp;width=500&amp;height=300&amp;dname=<?php echo rawurlencode($link['descr'] . ""); ?>" width="581" height="481" border="0" />
<?php endif; ?>
</td>
</tr>

View File

@ -113,7 +113,15 @@ div#legend {
#nav a, #nav a:visited {
text-decoration: none;
font-weight: bold;
color: #0000ee;
font-size: 1.15em;
color: #0066CC;
}
#nav a.selected:link, #nav a.selected:visited {
font-size: 1.15em;
text-decoration: none;
font-weight: bold;
color: #000000;
}
#nav a:hover {
@ -130,3 +138,8 @@ div#legend {
.customlinks a {
font-size: 0.85em;
}
.customlinks a, .customlinks a:visited {
text-decoration: none;
color: #0066CC;
}

View File

@ -32,7 +32,8 @@ $topas = getasstats_top($ntop);
Number of AS:
<input type="text" name="n" size="4" value="<?php echo $ntop; ?>" />
<input type="submit" value="Go" style="margin-right: 2em" />
Top AS | <a href="history.php">View an AS</a> | <a href="asset.php">View an AS-SET</a> | <a href="linkusage.php">Link usage</a></form>
<?php include('headermenu.inc'); ?>
</form>
</div>
<div class="pgtitle">Top <?php echo $ntop; ?> AS</div>
@ -80,10 +81,10 @@ echo join(" | ", $htmllinks);
</th>
<td>
<?php if ($showv6): ?>
<a href="history.php?v=4&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=4&amp;nolegend=1" width="581" height="207" border="0" /></a>
<a href="history.php?v=6&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=6&amp;nolegend=1" width="581" height="207" border="0" /></a>
<a href="history.php?v=4&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=4&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" width="581" height="207" border="0" /></a>
<a href="history.php?v=6&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=6&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" width="581" height="207" border="0" /></a>
<?php else: ?>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;nolegend=1" width="581" height="189" border="0" /></a>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" width="581" height="189" border="0" /></a>
<?php endif; ?>
</td>
</tr>

116
www/top12.php Normal file
View File

@ -0,0 +1,116 @@
<?php
/*
* $Id$
*
* (c) 2008 Monzoon Networks AG. All rights reserved.
*/
require_once('func.inc');
if (isset($_GET['n']))
$ntop = (int)$_GET['n'];
if ($ntop > 200)
$ntop = 200;
$topas = getasstats_top($ntop);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Refresh" content="300" />
<title>Top <?php echo $ntop; ?> AS</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="nav">
<form action="" method="get">
Number of AS:
<input type="text" name="n" size="4" value="<?php echo $ntop; ?>" />
<input type="submit" value="Go" style="margin-right: 2em" />
<?php include('headermenu.inc'); ?>
</form>
</div>
<div class="pgtitle">Top <?php echo $ntop; ?> AS</div>
<table class="astable">
<?php $i = 0; foreach ($topas as $as => $nbytes):
$asinfo = getASInfo($as);
$class = (($i % 2) == 0) ? "even" : "odd";
?>
<tr class="<?php echo $class; ?>">
<th>
<div class="title">
<?php
$flagfile = "flags/" . strtolower($asinfo['country']) . ".gif";
if (file_exists($flagfile)):
$is = getimagesize($flagfile);
?>
<img src="<?php echo $flagfile; ?>" <?php echo $is[3]; ?>>
<?php endif; ?>
AS<?php echo $as; ?>: <?php echo $asinfo['descr']; ?>
</div>
<div class="small">IPv4: ~ <?php echo format_bytes($nbytes[0]); ?> in /
<?php echo format_bytes($nbytes[1]); ?> out in the last 24 hours</div>
<?php if ($showv6): ?>
<div class="small">IPv6: ~ <?php echo format_bytes($nbytes[2]); ?> in /
<?php echo format_bytes($nbytes[3]); ?> out in the last 24 hours</div>
<?php endif; ?>
<?php if (!empty($customlinks)): ?>
<div class="customlinks">
<?php
$htmllinks = array();
foreach ($customlinks as $linkname => $url) {
$url = str_replace("%as%", $as, $url);
$htmllinks[] = "<a href=\"$url\" target=\"_blank\">" . htmlspecialchars($linkname) . "</a>\n";
}
echo join(" | ", $htmllinks);
?>
</div>
<?php endif; ?>
<div class="rank">
#<?php echo ($i+1); ?>
</div>
</th>
<td>
<?php if ($showv6): ?>
<a href="history.php?v=4&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=4&amp;nolegend=1&amp;start=<?php echo (time() - 12*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" width="581" height="207" border="0" /></a>
<a href="history.php?v=6&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=6&amp;nolegend=1&amp;start=<?php echo (time() - 12*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" width="581" height="207" border="0" /></a>
<?php else: ?>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;nolegend=1&amp;start=<?php echo (time() - 12*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" width="581" height="189" border="0" /></a>
<?php endif; ?>
</td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div id="legend">
<table>
<?php
$knownlinks = getknownlinks();
foreach ($knownlinks as $link) {
echo "<tr><td style=\"border: 4px solid #fff;\">";
echo "<table style=\"border-collapse: collapse; margin: 0; padding: 0\"><tr>";
echo "<td width=\"9\" height=\"18\" style=\"background-color: #{$link['color']}\">&nbsp;</td>";
echo "<td width=\"9\" height=\"18\" style=\"opacity: 0.73; background-color: #{$link['color']}\">&nbsp;</td>";
echo "</tr></table>";
echo "</td><td>&nbsp;" . $link['descr'] . "</td></tr>\n";
}
?>
</table>
</div>
<?php include('footer.inc'); ?>
</body>
</html>

116
www/top4.php Normal file
View File

@ -0,0 +1,116 @@
<?php
/*
* $Id$
*
* (c) 2008 Monzoon Networks AG. All rights reserved.
*/
require_once('func.inc');
if (isset($_GET['n']))
$ntop = (int)$_GET['n'];
if ($ntop > 200)
$ntop = 200;
$topas = getasstats_top($ntop);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Refresh" content="300" />
<title>Top <?php echo $ntop; ?> AS</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="nav">
<form action="" method="get">
Number of AS:
<input type="text" name="n" size="4" value="<?php echo $ntop; ?>" />
<input type="submit" value="Go" style="margin-right: 2em" />
<?php include('headermenu.inc'); ?>
</form>
</div>
<div class="pgtitle">Top <?php echo $ntop; ?> AS</div>
<table class="astable">
<?php $i = 0; foreach ($topas as $as => $nbytes):
$asinfo = getASInfo($as);
$class = (($i % 2) == 0) ? "even" : "odd";
?>
<tr class="<?php echo $class; ?>">
<th>
<div class="title">
<?php
$flagfile = "flags/" . strtolower($asinfo['country']) . ".gif";
if (file_exists($flagfile)):
$is = getimagesize($flagfile);
?>
<img src="<?php echo $flagfile; ?>" <?php echo $is[3]; ?>>
<?php endif; ?>
AS<?php echo $as; ?>: <?php echo $asinfo['descr']; ?>
</div>
<div class="small">IPv4: ~ <?php echo format_bytes($nbytes[0]); ?> in /
<?php echo format_bytes($nbytes[1]); ?> out in the last 24 hours</div>
<?php if ($showv6): ?>
<div class="small">IPv6: ~ <?php echo format_bytes($nbytes[2]); ?> in /
<?php echo format_bytes($nbytes[3]); ?> out in the last 24 hours</div>
<?php endif; ?>
<?php if (!empty($customlinks)): ?>
<div class="customlinks">
<?php
$htmllinks = array();
foreach ($customlinks as $linkname => $url) {
$url = str_replace("%as%", $as, $url);
$htmllinks[] = "<a href=\"$url\" target=\"_blank\">" . htmlspecialchars($linkname) . "</a>\n";
}
echo join(" | ", $htmllinks);
?>
</div>
<?php endif; ?>
<div class="rank">
#<?php echo ($i+1); ?>
</div>
</th>
<td>
<?php if ($showv6): ?>
<a href="history.php?v=4&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=4&amp;nolegend=1&amp;start=<?php echo (time() - 4*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>" width="581" height="207" border="0" /></a>
<a href="history.php?v=6&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=6&amp;nolegend=1&amp;start=<?php echo (time() - 4*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>" width="581" height="207" border="0" /></a>
<?php else: ?>
<a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;nolegend=1&amp;start=<?php echo (time() - 4*3600);?>&amp;end=<?php echo time(); ?>&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>" width="581" height="189" border="0" /></a>
<?php endif; ?>
</td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div id="legend">
<table>
<?php
$knownlinks = getknownlinks();
foreach ($knownlinks as $link) {
echo "<tr><td style=\"border: 4px solid #fff;\">";
echo "<table style=\"border-collapse: collapse; margin: 0; padding: 0\"><tr>";
echo "<td width=\"9\" height=\"18\" style=\"background-color: #{$link['color']}\">&nbsp;</td>";
echo "<td width=\"9\" height=\"18\" style=\"opacity: 0.73; background-color: #{$link['color']}\">&nbsp;</td>";
echo "</tr></table>";
echo "</td><td>&nbsp;" . $link['descr'] . "</td></tr>\n";
}
?>
</table>
</div>
<?php include('footer.inc'); ?>
</body>
</html>