2009-07-31 10:53:54 +00:00
< ? php
2009-05-11 13:43:59 +00:00
$hostname = $device [ 'hostname' ];
$hostid = $device [ 'interface_id' ];
$ifname = $interface [ 'ifDescr' ];
$ifIndex = $interface [ 'ifIndex' ];
$speed = humanspeed ( $interface [ 'ifSpeed' ]);
$ifalias = $interface [ 'name' ];
if ( $interface [ 'ifPhysAddress' ]) { $mac = " $interface[ifPhysAddress] " ; }
$color = " black " ;
if ( $interface [ 'ifAdminStatus' ] == " down " ) { $status = " <span class='grey'>Disabled</span> " ; }
if ( $interface [ 'ifAdminStatus' ] == " up " && $interface [ 'ifOperStatus' ] == " down " ) { $status = " <span class='red'>Enabled / Disconnected</span> " ; }
if ( $interface [ 'ifAdminStatus' ] == " up " && $interface [ 'ifOperStatus' ] == " up " ) { $status = " <span class='green'>Enabled / Connected</span> " ; }
$i = 1 ;
$inf = fixifName ( $ifname );
2009-10-28 13:49:37 +00:00
2009-07-31 10:53:54 +00:00
echo ( " <div style='clear: both;'> " );
2009-09-22 12:02:54 +00:00
if ( $_GET [ 'optd' ] == " top10 " ) {
if ( $_GET [ 'opte' ]) {
2009-10-12 09:48:40 +00:00
$period = $_GET [ 'opte' ];
} else { $period = " 1day " ; }
$from = " - " . $period ;
2009-09-24 14:38:17 +00:00
if ( $_GET [ 'optc' ]) {
$stat = $_GET [ 'optc' ];
} else { $stat = " bits " ; }
2009-10-28 13:49:37 +00:00
if ( $_GET [ 'optf' ]) {
$sort = $_GET [ 'optf' ];
} else { $sort = " in " ; }
2009-09-24 14:38:17 +00:00
echo ( " <div style=' margin:0px; float: left;';>
2009-10-28 13:49:37 +00:00
< div style = 'margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;' >
2009-09-24 14:38:17 +00:00
< span class = device - head > Day </ span >< br />
2009-10-28 13:49:37 +00:00
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ' ] .
" /macaccounting/ $stat /top10/1day/ $sort /'>
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ' ] .
" &stat= $stat &type=mac_acc_total&sort= $sort &from=-1day&to=now&width=150&height=50' />
2009-09-22 12:02:54 +00:00
</ a >
2009-09-24 14:38:17 +00:00
</ div >
2009-10-28 13:49:37 +00:00
< div style = 'margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;' >
< span class = device - head > Two Day </ span >< br />
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ' ] .
" /macaccounting/ $stat /top10/2day/ $sort /'>
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ' ] .
" &stat= $stat &type=mac_acc_total&sort= $sort &from=-2day&to=now&width=150&height=50' />
</ a >
</ div >
< div style = 'margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;' >
2009-09-24 14:38:17 +00:00
< span class = device - head > Week </ span >< br />
2009-10-28 13:49:37 +00:00
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ']."/macaccounting/$stat/top10/1week/$sort/' >
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ']."&type=mac_acc_total&sort=$sort&stat=$stat&from=-1week&to=now&width=150&height=50' />
2009-09-22 12:02:54 +00:00
</ a >
2009-09-24 14:38:17 +00:00
</ div >
2009-10-28 13:49:37 +00:00
< div style = 'margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;' >
2009-09-24 14:38:17 +00:00
< span class = device - head > Month </ span >< br />
2009-10-28 13:49:37 +00:00
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ']."/macaccounting/$stat/top10/1month/$sort/' >
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ']."&type=mac_acc_total&sort=$sort&stat=$stat&from=-1month&to=now&width=150&height=50' />
2009-09-22 12:02:54 +00:00
</ a >
2009-09-24 14:38:17 +00:00
</ div >
2009-10-28 13:49:37 +00:00
< div style = 'margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;' >
2009-09-24 14:38:17 +00:00
< span class = device - head > Year </ span >< br />
2009-10-28 13:49:37 +00:00
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ']."/macaccounting/$stat/top10/1year/$sort/' >
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ']."&type=mac_acc_total&sort=$sort&stat=$stat&from=-1year&to=now&width=150&height=50' />
2009-09-22 12:02:54 +00:00
</ a >
2009-09-24 14:38:17 +00:00
</ div >
</ div >
< div style = 'float: left;' >
2009-10-28 13:49:37 +00:00
< img src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ']."&type=mac_acc_total&sort=$sort&stat=$stat&from=$from&to=now&width=750&height=245' />
2009-09-24 14:38:17 +00:00
</ div >
< div style = ' margin:0px; float: left;' ; >
2009-10-28 13:49:37 +00:00
< div style = 'margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;' >
2009-09-24 14:38:17 +00:00
< span class = device - head > Traffic </ span >< br />
2009-10-28 13:49:37 +00:00
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ']."/macaccounting/bits/top10/$period/$sort/' >
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ']."&stat=bits&type=mac_acc_total&sort=$sort&from=$from&to=now&width=150&height=50' />
2009-09-24 14:38:17 +00:00
</ a >
</ div >
2009-10-28 13:49:37 +00:00
< div style = 'margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;' >
2009-09-24 14:38:17 +00:00
< span class = device - head > Packets </ span >< br />
2009-10-28 13:49:37 +00:00
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ']."/macaccounting/pkts/top10/$period/$sort/' >
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ']."&stat=pkts&type=mac_acc_total&sort=$sort&from=$from&to=now&width=150&height=50' />
</ a >
</ div >
< div style = 'margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;' >
< span class = device - head > Top Input </ span >< br />
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ' ] .
" /macaccounting/ $stat /top10/ $period /in/'>
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ' ] .
" &stat= $stat &type=mac_acc_total&sort=in&from= $from &to=now&width=150&height=50' />
</ a >
</ div >
< div style = 'margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;' >
< span class = device - head > Top Output </ span >< br />
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ' ] .
" /macaccounting/ $stat /top10/ $period /out/'>
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ' ] .
" &stat= $stat &type=mac_acc_total&sort=out&from= $from &to=now&width=150&height=50' />
</ a >
</ div >
< div style = 'margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;' >
< span class = device - head > Top Aggregate </ span >< br />
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/interface/".$interface[' interface_id ' ] .
" /macaccounting/ $stat /top10/ $period /both/'>
< img style = 'border: #5e5e5e 2px;' valign = middle src = '".$config[' base_url ']."/graph.php?port=".$interface[' interface_id ' ] .
" &stat= $stat &type=mac_acc_total&sort=both&from= $from &to=now&width=150&height=50' />
2009-09-24 14:38:17 +00:00
</ a >
</ div >
2009-10-28 13:49:37 +00:00
2009-09-22 12:02:54 +00:00
</ div >
" );
unset ( $query );
2009-10-28 13:49:37 +00:00
} else {
2009-09-18 14:45:34 +00:00
2009-10-28 13:49:37 +00:00
$query = mysql_query ( " SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) 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 " );
2009-09-22 12:02:54 +00:00
while ( $acc = mysql_fetch_array ( $query )) {
if ( ! is_integer ( $i / 2 )) { $row_colour = $list_colour_a ; } else { $row_colour = $list_colour_b ; }
2009-05-11 13:43:59 +00:00
$addy = mysql_fetch_array ( mysql_query ( " SELECT * FROM ipv4_mac where mac_address = ' " . $acc [ 'mac' ] . " ' " ));
2010-02-02 19:24:12 +00:00
$name = gethostbyaddr ( $addy [ 'ipv4_address' ]);
if ( $name == $addy [ 'ipv4_address' ]) { unset ( $name ); }
2009-05-11 13:43:59 +00:00
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' ] . " ' " );
$peer_info = mysql_fetch_array ( $peer_query );
2009-07-31 10:53:54 +00:00
} else { unset ( $peer_info ); }
2009-05-11 13:43:59 +00:00
if ( $peer_info ) { $asn = " AS " . $peer_info [ 'bgpPeerRemoteAs' ]; $astext = $peer_info [ 'astext' ]; } else {
2009-07-31 10:53:54 +00:00
unset ( $as ); unset ( $astext ); unset ( $asn );
2009-05-11 13:43:59 +00:00
}
2009-09-22 12:02:54 +00:00
if ( $_GET [ 'optc' ]) {
$graph_type = " mac_acc_ " . $_GET [ 'optc' ];
} else {
$graph_type = " mac_acc_bits " ;
}
2009-09-18 14:45:34 +00:00
2009-09-22 12:02:54 +00:00
if ( $_GET [ 'optd' ] == " thumbs " ) {
2009-07-31 10:53:54 +00:00
if ( ! $asn ) { $asn = " No Session " ; }
echo ( " <div style='display: block; padding: 3px; margin: 3px; min-width: 223px; max-width:223px; min-height:90px; max-height:90px; text-align: center; float: left; background-color: #e5e5e5;'>
" . $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> \
2009-09-18 14:45:34 +00:00
< img src = \ 'graph.php?id=" . $acc[' ma_id ' ] . " &type= $graph_type &from=-2day&to= $now &width=450&height=150 \ '> \
2009-07-31 10:53:54 +00:00
', CENTER, LEFT, FGCOLOR, ' #e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >
2009-09-18 14:45:34 +00:00
< img src = 'graph.php?id=" . $acc[' ma_id '] . "&type=$graph_type&from=-2day&to=$now&width=215&height=45' ></ a >
2009-07-31 10:53:54 +00:00
< span style = 'font-size: 10px;' > " . $name . " </ span >
</ div > " );
} else {
2009-09-18 14:45:34 +00:00
echo ( " <div style='background-color: $row_colour ; padding: 8px;'> " );
2009-07-31 10:53:54 +00:00
2009-05-11 13:43:59 +00:00
echo ( "
< table >
< tr >
< td class = list - large width = 200 > " .mac_clean_to_readable( $acc['mac'] ). " </ td >
< td class = list - large width = 200 > " . $addy['ipv4_address'] . " </ td >
< td class = list - large width = 500 > " . $name . " </ td >
2009-10-28 13:49:37 +00:00
< td class = list - large width = 100 > " .formatRates( $acc['cipMacHCSwitchedBytes_input_rate'] / 8). " </ td >
< td class = list - large width = 100 > " .formatRates( $acc['cipMacHCSwitchedBytes_output_rate'] / 8). " </ td >
2009-05-11 13:43:59 +00:00
</ tr >
</ table >
" );
$peer_info [ 'astext' ];
2009-09-22 12:02:54 +00:00
$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 " ;
$weekly_traffic = " graph.php?id= " . $acc [ 'ma_id' ] . " &type= $graph_type &from= $week &to= $now &width=210&height=100 " ;
$weekly_url = " graph.php?id= " . $acc [ 'ma_id' ] . " &type= $graph_type &from= $week &to= $now &width=500&height=150 " ;
$monthly_traffic = " graph.php?id= " . $acc [ 'ma_id' ] . " &type= $graph_type &from= $month &to= $now &width=210&height=100 " ;
$monthly_url = " graph.php?id= " . $acc [ 'ma_id' ] . " &type= $graph_type &from= $month &to= $now &width=500&height=150 " ;
$yearly_traffic = " graph.php?id= " . $acc [ 'ma_id' ] . " &type= $graph_type &from= $year &to= $now &width=210&height=100 " ;
$yearly_url = " graph.php?id= " . $acc [ 'ma_id' ] . " &type= $graph_type &from= $year &to= $now &width=500&height=150 " ;
2009-05-11 13:43:59 +00:00
2009-09-22 12:02:54 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'ma_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $daily_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " ); \" onmouseout= \" return nd(); \" >
2009-05-11 13:43:59 +00:00
< img src = '$daily_traffic' border = 0 ></ a > " );
2009-09-22 12:02:54 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'ma_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $weekly_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " ); \" onmouseout= \" return nd(); \" >
2009-05-11 13:43:59 +00:00
< img src = '$weekly_traffic' border = 0 ></ a > " );
2009-09-22 12:02:54 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'ma_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $monthly_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " , WIDTH, 350); \" onmouseout= \" return nd(); \" >
2009-05-11 13:43:59 +00:00
< img src = '$monthly_traffic' border = 0 ></ a > " );
2009-09-22 12:02:54 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'ma_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $yearly_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " , WIDTH, 350); \" onmouseout= \" return nd(); \" >
2009-05-11 13:43:59 +00:00
< img src = '$yearly_traffic' border = 0 ></ a > " );
echo ( " </div> " );
2009-09-18 14:45:34 +00:00
$i ++ ;
2009-05-11 13:43:59 +00:00
}
2009-07-31 10:53:54 +00:00
}
2009-10-28 13:49:37 +00:00
}
2009-05-11 13:43:59 +00:00
?>