improved integration with mac accounting. added packets to mac accounting

git-svn-id: http://www.observium.org/svn/observer/trunk@470 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-09-18 14:45:34 +00:00
parent ecaf1cd417
commit 128a26a4f1
7 changed files with 120 additions and 81 deletions

View File

@@ -42,14 +42,45 @@ $interface = mysql_fetch_array($interface_query);
$broke = yes;
}
if( !$broke)
{ }
echo("<div style='clear: both;'>");
echo("
<div style='margin:auto; text-align: center; margin-top: 0px; margin-bottom: 10px;'>
<b class='rounded'>
<b class='rounded1'><b></b></b>
<b class='rounded2'><b></b></b>
<b class='rounded3'></b>
<b class='rounded4'></b>
<b class='rounded5'></b></b>
<div class='roundedfg' style='padding: 0px 5px;'>
<div style='margin: auto; text-align: left; padding: 2px 5px; padding-left: 11px; clear: both; display:block; height:20px;'>
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/interface/".$interface['interface_id']."/'>Graphs</a> |
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/interface/".$interface['interface_id']."/arp/'>ARP Table</a>");
if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0)){
echo(" | Mac Accounting :
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/interface/".$interface['interface_id']."/macaccounting/bits/'>Bits</a>
(<a href='".$config['base_url']."/device/" . $device['device_id'] . "/interface/".$interface['interface_id']."/macaccounting/bits/thumbs/'>Mini</a>) |
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/interface/".$interface['interface_id']."/macaccounting/pkts/'>Packets</a>
(<a href='".$config['base_url']."/device/" . $device['device_id'] . "/interface/".$interface['interface_id']."/macaccounting/pkts/thumbs/'>Mini</a>)");
}
echo("</div>
</div>
<b class='rounded'>
<b class='rounded5'></b>
<b class='rounded4'></b>
<b class='rounded3'></b>
<b class='rounded2'><b></b></b>
<b class='rounded1'><b></b></b></b>
</div>
");
if($_GET['optb']) {
include("pages/device/".mres($_GET['optb']).".php");
include("pages/device/port/".mres($_GET['optb']).".php");
} else {

View File

@@ -1,11 +1,5 @@
<?php
echo("<div style='width: 100%; text-align: right; padding-bottom: 10px; clear: both; display:block; height:20px;'>
<a href='device/".$interface['device_id']."/interface/".$interface['interface_id']."/macaccounting/'>Full</a> |
<a href='device/".$interface['device_id']."/interface/".$interface['interface_id']."/macaccounting/thumbs/'>Compact</a>
</div> ");
$hostname = $device['hostname'];
$hostid = $device['interface_id'];
$ifname = $interface['ifDescr'];
@@ -24,20 +18,19 @@ echo("<div style='width: 100%; text-align: right; padding-bottom: 10px; clear: b
$i = 1;
$inf = fixifName($ifname);
$bg="#ffffff";
$query = mysql_query("SELECT *, (M.bps_in + M.bps_out) as bps FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '".$interface['interface_id']."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id ORDER BY bps DESC");
echo("<div style='clear: both;'>");
while($acc = mysql_fetch_array($query)) {
if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."'"));
$name = gethostbyaddr($addy['ipv4_address']);
if($name == $addy['ipv4_address']) { unset ($name); }
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
if(mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"),0)) {
$peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'");
@@ -50,7 +43,13 @@ echo("<div style='width: 100%; text-align: right; padding-bottom: 10px; clear: b
unset ($as); unset ($astext); unset($asn);
}
if($_GET['optc'] == "thumbs") {
if($_GET['optc']) {
$graph_type = "mac_acc_" . $_GET['optc'];
} else {
$graph_type = "mac_acc_bits";
}
if($_GET['optd'] == "thumbs") {
if(!$asn) { $asn = "No Session"; }
@@ -58,16 +57,16 @@ echo("<div style='width: 100%; text-align: right; padding-bottom: 10px; clear: b
".$addy['ipv4_address']." - ".$asn."
<a href='#' onmouseover=\"return overlib('\
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #555555;\'>".$name." - ".$addy['ipv4_address']." - ".$asn."</div>\
<img src=\'graph.php?id=" . $acc['ma_id'] . "&type=mac_acc&from=-2day&to=$now&width=450&height=150\'>\
<img src=\'graph.php?id=" . $acc['ma_id'] . "&type=$graph_type&from=-2day&to=$now&width=450&height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >
<img src='graph.php?id=" . $acc['ma_id'] . "&type=mac_acc&from=-2day&to=$now&width=215&height=45'></a>
<img src='graph.php?id=" . $acc['ma_id'] . "&type=$graph_type&from=-2day&to=$now&width=215&height=45'></a>
<span style='font-size: 10px;'>".$name."</span>
</div>");
} else {
echo("<div style='background-color: $bg; padding: 8px;'>");
echo("<div style='background-color: $row_colour; padding: 8px;'>");
echo("
<table>
@@ -83,9 +82,6 @@ echo("<div style='width: 100%; text-align: right; padding-bottom: 10px; clear: b
$peer_info['astext'];
$graph_type = "mac_acc";
$daily_traffic = "graph.php?id=" . $acc['ma_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100";
$daily_url = "graph.php?id=" . $acc['ma_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150";
@@ -109,7 +105,7 @@ echo("<div style='width: 100%; text-align: right; padding-bottom: 10px; clear: b
echo("</div>");
$i++;
}
}

View File

@@ -89,16 +89,20 @@ if($_GET['optc'] == thumbs) {
} elseif(mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$device['device_id']."' AND bgpPeerIdentifier ='".$arp['ipv4_address']."'"),0)) {
$peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$device['device_id']."' AND bgpPeerIdentifier = '".$arp['ipv4_address']."'");
$peer_info = mysql_fetch_array($peer_query);
$remote_host = "AS".$peer_info['bgpPeerRemoteAs'];
$remote_port = truncate($peer_info['astext'], 24);
$remote_port = "AS".$peer_info['bgpPeerRemoteAs'];
$remote_host = $peer_info['astext'];
} elseif($mac_acc['interface_id'] == $interface['interface_id']) {
$remote_host = gethostbyaddr($arp['ipv4_address']);
if($remote_host == $arp['ipv4_address']) { unset ($remote_host); }
$remote_port = "";
} else {
$remote_host = "";
$remote_port = "";
}
echo("<td>$remote_host</td><td>$remote_port</td>");
echo("<td>".truncate($remote_host, 24, "")."</td><td>$remote_port</td>");
if ($mac_acc['interface_id'] == $interface['interface_id']) {
echo("<td>".formatRates($mac_acc['bps_out'])."</td><td>".formatRates($mac_acc['bps_in'])."</td>");
$style = "onmouseover=\"return overlib('<img src=\'graph.php?id=" . $mac_acc['ma_id'] . "&type=mac_acc&from=$day&to=$now&width=500&height=150\'>', LEFT".$config['overlib_defaults'].", WIDTH, 500);\" onmouseout=\"return nd();\"";
echo("<td><a $style>".formatRates($mac_acc['bps_out'])."</a></td><td><a $style>".formatRates($mac_acc['bps_in'])."</a></td>");
} else {
echo("<td></td><td></td>");
}