Disabled";
}
if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') {
$status = "Enabled / Disconnected";
}
if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') {
$status = "Enabled / Connected";
}
$i = 1;
$inf = fixifName($ifname);
echo "
";
if ($vars['subview'] == 'top10') {
if (!isset($vars['sort'])) {
$vars['sort'] = 'in';
}
if (!isset($vars['period'])) {
$vars['period'] = '1day';
}
$from = '-'.$vars['period'];
echo "
";
unset($query);
}
else {
$query = 'SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) as bps FROM `mac_accounting` AS M,
`ports` AS I, `devices` AS D WHERE M.port_id = ? AND I.port_id = M.port_id AND I.device_id = D.device_id ORDER BY bps DESC';
$param = array($port['port_id']);
foreach (dbFetchRows($query, $param) as $acc) {
if (!is_integer($i / 2)) {
$row_colour = $list_colour_a;
}
else {
$row_colour = $list_colour_b;
}
$addy = dbFetchRow('SELECT * FROM ipv4_mac where mac_address = ?', array($acc['mac']));
// $name = gethostbyaddr($addy['ipv4_address']); FIXME - Maybe some caching for this?
$arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($addy['ipv4_address']));
if ($arp_host) {
$arp_name = generate_device_link($arp_host);
$arp_name .= ' '.generate_port_link($arp_host);
}
else {
unset($arp_if);
}
if ($name == $addy['ipv4_address']) {
unset($name);
}
if (dbFetchCell('SELECT count(*) FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?', array($acc['device_id'], $addy['ipv4_address']))) {
$peer_info = dbFetchRow('SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?', array($acc['device_id'], $addy['ipv4_address']));
}
else {
unset($peer_info);
}
if ($peer_info) {
$asn = 'AS'.$peer_info['bgpPeerRemoteAs'];
$astext = $peer_info['astext'];
}
else {
unset($as);
unset($astext);
unset($asn);
}
if ($vars['graph']) {
$graph_type = 'macaccounting_'.$vars['graph'];
}
else {
$graph_type = 'macaccounting_bits';
}
if ($vars['subview'] == 'minigraphs') {
if (!$asn) {
$asn = 'No Session';
}
echo "
\

\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >
".$name.'
';
}
else {
echo "";
echo ('
'.mac_clean_to_readable($acc['mac']).' |
'.$addy['ipv4_address'].' |
'.$name.' '.$arp_name.' |
'.formatRates(($acc['cipMacHCSwitchedBytes_input_rate'] / 8)).' |
'.formatRates(($acc['cipMacHCSwitchedBytes_output_rate'] / 8)).' |
');
$peer_info['astext'];
$graph_array['type'] = $graph_type;
$graph_array['id'] = $acc['ma_id'];
$graph_array['height'] = '100';
$graph_array['width'] = '216';
$graph_array['to'] = $config['time']['now'];
echo '
';
include 'includes/print-graphrow.inc.php';
echo ' |
';
$i++;
}//end if
}//end foreach
}//end if