2011-04-27 17:42:11 +00:00
< ? php
2007-04-03 14:10:23 +00:00
2011-03-17 11:29:23 +00:00
# This file prints a table row for each interface
2007-06-24 14:56:47 +00:00
2011-03-17 11:29:23 +00:00
$interface [ 'device_id' ] = $device [ 'device_id' ];
$interface [ 'hostname' ] = $device [ 'hostname' ];
2008-11-05 15:24:44 +00:00
2011-03-17 11:29:23 +00:00
$if_id = $interface [ 'interface_id' ];
2010-02-02 19:24:12 +00:00
2011-03-17 11:29:23 +00:00
$interface = ifLabel ( $interface );
2007-04-07 21:15:23 +00:00
2011-05-01 12:37:43 +00:00
if ( $int_colour )
{
$row_colour = $int_colour ;
} else {
if ( ! is_integer ( $i / 2 )) { $row_colour = $list_colour_a ; } else { $row_colour = $list_colour_b ; }
}
2010-07-18 11:38:38 +00:00
2011-05-12 22:14:56 +00:00
$port_adsl = dbFetchRow ( " SELECT * FROM `ports_adsl` WHERE `interface_id` = ? " , array ( $interface [ 'interface_id' ]));
2010-07-18 11:38:38 +00:00
2011-03-17 11:29:23 +00:00
if ( $interface [ 'ifInErrors_delta' ] > 0 || $interface [ 'ifOutErrors_delta' ] > 0 )
{
$error_img = generate_port_link ( $interface , " <img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0> " , " port_errors " );
} else { $error_img = " " ; }
2007-06-24 14:56:47 +00:00
2011-05-12 22:14:56 +00:00
if ( dbFetchCell ( " SELECT COUNT(*) FROM `mac_accounting` WHERE `interface_id` = ? " , array ( $interface [ 'interface_id' ])))
2011-03-17 11:29:23 +00:00
{
2011-04-09 16:08:39 +00:00
$mac = " <a href='device/ " . $interface [ 'device_id' ] . " /port/ " . $interface [ 'interface_id' ] . " /macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'></a> " ;
2011-03-17 11:29:23 +00:00
} else { $mac = " " ; }
2009-09-24 14:38:17 +00:00
2011-04-09 16:08:39 +00:00
echo ( " <tr style= \" background-color: $row_colour ; \" valign=top onmouseover= \" this.style.backgroundColor=' $list_highlight '; \" onmouseout= \" this.style.backgroundColor=' $row_colour '; \" onclick= \" location.href='device/ " . $device [ 'device_id' ] . " /port/ " . $interface [ 'interface_id' ] . " /' \" style='cursor: pointer;'>
2011-03-17 11:29:23 +00:00
< td valign = top width = 350 > " );
echo ( " <span class=list-large>
" . generate_port_link( $interface , $interface['ifIndex'] . " . " . $interface['label'] ) . " $error_img $mac
</ span >< br />< span class = interface - desc > " . $interface['ifAlias'] . " </ span > " );
2008-11-05 15:24:44 +00:00
2011-03-17 11:29:23 +00:00
if ( $interface [ 'ifAlias' ]) { echo ( " <br /> " ); }
2008-03-31 13:08:17 +00:00
2011-03-17 11:29:23 +00:00
unset ( $break );
2011-03-30 16:28:24 +00:00
2011-03-17 11:29:23 +00:00
if ( $port_details )
{
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `ipv4_addresses` WHERE `interface_id` = ? " , array ( $interface [ 'interface_id' ])) as $ip )
{
2011-05-12 22:20:05 +00:00
echo ( " $break <a class=interface-desc href= \" javascript:popUp('/netcmd.php?cmd=whois&query= $ip[ipv4_address] ') \" > " . $ip [ 'ipv4_address' ] . " / " . $ip [ 'ipv4_prefixlen' ] . " </a> " );
2011-03-17 11:29:23 +00:00
$break = " <br /> " ;
2009-04-23 21:13:56 +00:00
}
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ? " , array ( $interface [ 'interface_id' ])) as $ip6 )
{
2011-03-28 09:11:05 +00:00
echo ( " $break <a class=interface-desc href= \" javascript:popUp('/netcmd.php?cmd=whois&query= " . $ip6 [ 'ipv6_address' ] . " ') \" > " . Net_IPv6 :: compress ( $ip6 [ 'ipv6_address' ]) . " / " . $ip6 [ 'ipv6_prefixlen' ] . " </a> " );
2011-03-17 11:29:23 +00:00
$break = " <br /> " ;
2009-02-02 15:38:34 +00:00
}
2011-03-17 11:29:23 +00:00
}
echo ( " </span> " );
echo ( " </td><td width=100> " );
if ( $port_details )
{
$interface [ 'graph_type' ] = " port_bits " ;
2011-05-17 19:21:20 +00:00
echo ( generate_port_link ( $interface , " <img src='graph.php?type=port_bits&id= " . $interface [ 'interface_id' ] . " &from= " . $config [ 'time' ][ 'day' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=100&height=20&legend=no&bg= " . str_replace ( " # " , " " , $row_colour ) . " '> " ));
2011-03-17 11:29:23 +00:00
$interface [ 'graph_type' ] = " port_upkts " ;
2011-05-17 19:21:20 +00:00
echo ( generate_port_link ( $interface , " <img src='graph.php?type=port_upkts&id= " . $interface [ 'interface_id' ] . " &from= " . $config [ 'time' ][ 'day' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=100&height=20&legend=no&bg= " . str_replace ( " # " , " " , $row_colour ) . " '> " ));
2011-03-17 11:29:23 +00:00
$interface [ 'graph_type' ] = " port_errors " ;
2011-05-17 19:21:20 +00:00
echo ( generate_port_link ( $interface , " <img src='graph.php?type=port_errors&id= " . $interface [ 'interface_id' ] . " &from= " . $config [ 'time' ][ 'day' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=100&height=20&legend=no&bg= " . str_replace ( " # " , " " , $row_colour ) . " '> " ));
2011-03-17 11:29:23 +00:00
}
echo ( " </td><td width=120> " );
if ( $interface [ 'ifOperStatus' ] == " up " )
{
$interface [ 'in_rate' ] = $interface [ 'ifInOctets_rate' ] * 8 ;
$interface [ 'out_rate' ] = $interface [ 'ifOutOctets_rate' ] * 8 ;
$in_perc = @ round ( $interface [ 'in_rate' ] / $interface [ 'ifSpeed' ] * 100 );
$out_perc = @ round ( $interface [ 'in_rate' ] / $interface [ 'ifSpeed' ] * 100 );
echo ( " <img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour ( $in_perc ) . " '> " . formatRates ( $interface [ 'in_rate' ]) . " <br />
< img align = absmiddle src = 'images/16/arrow_out.png' > < span style = 'color: " . percent_colour($out_perc) . "' > " .formatRates( $interface['out_rate'] ) . " < br />
< img src = 'images/icons/arrow_pps_in.png' align = absmiddle > " .format_bi( $interface['ifInUcastPkts_rate'] ). " pps </ span >< br />
< img src = 'images/icons/arrow_pps_out.png' align = absmiddle > " .format_bi( $interface['ifOutUcastPkts_rate'] ). " pps </ span > " );
}
echo ( " </td><td width=75> " );
if ( $interface [ 'ifSpeed' ]) { echo ( " <span class=box-desc> " . humanspeed ( $interface [ 'ifSpeed' ]) . " </span> " ); }
echo ( " <br /> " );
if ( $interface [ ifDuplex ] != " unknown " ) { echo ( " <span class=box-desc> " . $interface [ 'ifDuplex' ] . " </span> " ); } else { echo ( " - " ); }
if ( $device [ 'os' ] == " ios " || $device [ 'os' ] == " iosxe " )
{
if ( $interface [ 'ifTrunk' ]) {
echo ( " <span class=box-desc><span class=red> " . $interface [ 'ifTrunk' ] . " </span></span> " );
} elseif ( $interface [ 'ifVlan' ]) {
echo ( " <span class=box-desc><span class=blue>VLAN " . $interface [ 'ifVlan' ] . " </span></span> " );
} elseif ( $interface [ 'ifVrf' ]) {
2011-05-12 22:14:56 +00:00
$vrf = dbFetchRow ( " SELECT * FROM vrfs WHERE vrf_id = ? " , array ( $interface [ 'ifVrf' ]));
2011-03-17 11:29:23 +00:00
echo ( " <span style='color: green;'> " . $vrf [ 'vrf_name' ] . " </span> " );
2007-06-24 14:56:47 +00:00
}
2011-03-17 11:29:23 +00:00
}
2009-04-23 21:13:56 +00:00
2011-03-17 11:29:23 +00:00
if ( $port_adsl [ 'adslLineCoding' ])
{
echo ( " </td><td width=150> " );
2011-03-30 12:07:08 +00:00
echo ( $port_adsl [ 'adslLineCoding' ] . " / " . rewrite_adslLineType ( $port_adsl [ 'adslLineType' ]));
2007-04-09 01:01:48 +00:00
echo ( " <br /> " );
2011-03-17 11:29:23 +00:00
echo ( " Sync: " . formatRates ( $port_adsl [ 'adslAtucChanCurrTxRate' ]) . " / " . formatRates ( $port_adsl [ 'adslAturChanCurrTxRate' ]));
echo ( " <br /> " );
echo ( " Max: " . formatRates ( $port_adsl [ 'adslAtucCurrAttainableRate' ]) . " / " . formatRates ( $port_adsl [ 'adslAturCurrAttainableRate' ]));
echo ( " </td><td width=150> " );
echo ( " Atten: " . $port_adsl [ 'adslAtucCurrAtn' ] . " dB/ " . $port_adsl [ 'adslAturCurrAtn' ] . " dB " );
echo ( " <br /> " );
echo ( " SNR: " . $port_adsl [ 'adslAtucCurrSnrMgn' ] . " dB/ " . $port_adsl [ 'adslAturCurrSnrMgn' ] . " dB " );
} else {
echo ( " </td><td width=150> " );
if ( $interface [ 'ifType' ] && $interface [ 'ifType' ] != " " ) { echo ( " <span class=box-desc> " . fixiftype ( $interface [ 'ifType' ]) . " </span> " ); } else { echo ( " - " ); }
echo ( " <br /> " );
if ( $ifHardType && $ifHardType != " " ) { echo ( " <span class=box-desc> " . $ifHardType . " </span> " ); } else { echo ( " - " ); }
echo ( " </td><td width=150> " );
2011-04-24 01:54:30 +00:00
if ( $interface [ 'ifPhysAddress' ] && $interface [ 'ifPhysAddress' ] != " " ) { echo ( " <span class=box-desc> " . formatMac ( $interface [ 'ifPhysAddress' ]) . " </span> " ); } else { echo ( " - " ); }
2011-03-17 11:29:23 +00:00
echo ( " <br /> " );
if ( $interface [ 'ifMtu' ] && $interface [ 'ifMtu' ] != " " ) { echo ( " <span class=box-desc>MTU " . $interface [ 'ifMtu' ] . " </span> " ); } else { echo ( " - " ); }
}
2007-04-03 14:10:23 +00:00
echo ( " </td> " );
2011-03-17 11:29:23 +00:00
echo ( " <td width=375 valign=top class=interface-desc> " );
if ( strpos ( $interface [ 'label' ], " oopback " ) === false && ! $graph_type )
{
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_interface_id = ? AND L.remote_interface_id = I.interface_id AND I.device_id = D.device_id " , array ( $if_id )) as $link )
2011-03-17 11:29:23 +00:00
{
2010-08-02 22:09:52 +00:00
# echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "</a><br />");
2008-04-13 16:27:05 +00:00
# $br = "<br />";
2011-03-17 11:29:23 +00:00
$int_links [ $link [ 'interface_id' ]] = $link [ 'interface_id' ];
$int_links_phys [ $link [ 'interface_id' ]] = 1 ;
2008-10-28 18:25:53 +00:00
}
2011-03-17 11:29:23 +00:00
unset ( $br );
if ( $port_details )
{ ## Show which other devices are on the same subnet as this interface
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = ? AND `ipv4_address` NOT LIKE '127.%' " , array ( $interface [ 'interface_id' ])) as $net )
2011-03-17 11:29:23 +00:00
{
$ipv4_network_id = $net [ 'ipv4_network_id' ];
$sql = " SELECT I.interface_id FROM ipv4_addresses AS A, ports AS I, devices AS D
WHERE A . interface_id = I . interface_id
2011-05-12 22:14:56 +00:00
AND A . ipv4_network_id = ? AND D . device_id = I . device_id
AND D . device_id != ? " ;
$array = array ( $net [ 'ipv4_network_id' ], $device [ 'device_id' ]);
2011-05-12 22:20:05 +00:00
foreach ( dbFetchRows ( $sql , $array ) AS $new )
2011-03-17 11:29:23 +00:00
{
echo ( $new [ 'ipv4_network_id' ]);
$this_ifid = $new [ 'interface_id' ];
$this_hostid = $new [ 'device_id' ];
$this_hostname = $new [ 'hostname' ];
$this_ifname = fixifName ( $new [ 'label' ]);
$int_links [ $this_ifid ] = $this_ifid ;
$int_links_v4 [ $this_ifid ] = 1 ;
}
}
2010-02-25 01:30:07 +00:00
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT ipv6_network_id FROM ipv6_addresses WHERE interface_id = ? " , array ( $interface [ 'interface_id' ])) as $net )
2011-03-17 11:29:23 +00:00
{
$ipv6_network_id = $net [ 'ipv6_network_id' ];
$sql = " SELECT I.interface_id FROM ipv6_addresses AS A, ports AS I, devices AS D
WHERE A . interface_id = I . interface_id
2011-05-12 22:14:56 +00:00
AND A . ipv6_network_id = ? AND D . device_id = I . device_id
AND D . device_id != ? AND A . ipv6_origin != 'linklayer' AND A . ipv6_origin != 'wellknown' " ;
$array = array ( $net [ 'ipv6_network_id' ], $device [ 'device_id' ]);
2011-05-12 22:20:05 +00:00
foreach ( dbFetchRows ( $sql , $array ) AS $new )
2011-03-17 11:29:23 +00:00
{
echo ( $new [ 'ipv6_network_id' ]);
$this_ifid = $new [ 'interface_id' ];
$this_hostid = $new [ 'device_id' ];
$this_hostname = $new [ 'hostname' ];
$this_ifname = fixifName ( $new [ 'label' ]);
$int_links [ $this_ifid ] = $this_ifid ;
$int_links_v6 [ $this_ifid ] = 1 ;
}
2010-02-25 01:30:07 +00:00
}
2011-03-17 11:29:23 +00:00
}
2010-02-25 01:30:07 +00:00
2011-03-17 11:29:23 +00:00
foreach ( $int_links as $int_link )
{
2011-05-12 22:14:56 +00:00
$link_if = dbFetchRow ( " SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.interface_id = ? " , array ( $int_link ));
2007-06-24 14:56:47 +00:00
2011-03-17 11:29:23 +00:00
echo ( " $br " );
2007-06-24 14:56:47 +00:00
2011-03-17 11:29:23 +00:00
if ( $int_links_phys [ $int_link ]) { echo ( " <img align=absmiddle src='images/16/connect.png'> " ); } else {
echo ( " <img align=absmiddle src='images/16/bullet_go.png'> " ); }
2007-06-24 14:56:47 +00:00
2011-03-27 10:21:19 +00:00
echo ( " <b> " . generate_port_link ( $link_if , makeshortif ( $link_if [ 'label' ])) . " on " . generate_device_link ( $link_if , shorthost ( $link_if [ 'hostname' ])));
2007-06-24 14:56:47 +00:00
2011-03-17 11:29:23 +00:00
if ( $int_links_v6 [ $int_link ]) { echo ( " <b style='color: #a10000;'>v6</b> " ); }
if ( $int_links_v4 [ $int_link ]) { echo ( " <b style='color: #00a100'>v4</b> " ); }
$br = " <br /> " ;
}
# unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
}
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `pseudowires` WHERE `interface_id` = ? " , array ( $interface [ 'interface_id' ])) as $pseudowire )
2011-03-17 11:29:23 +00:00
{
#`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`
2011-05-12 22:14:56 +00:00
$pw_peer_dev = dbFetchRow ( " SELECT * FROM `devices` WHERE `device_id` = ? " , array ( $pseudowire [ 'peer_device_id' ]));
$pw_peer_int = dbFetchRow ( " SELECT * FROM `ports` AS I, pseudowires AS P WHERE I.device_id = ? AND P.cpwVcID = ? AND P.interface_id = I.interface_id " , array ( $pseudowire [ 'peer_device_id' ], $pseudowire [ 'cpwVcID' ]));
2011-03-17 11:29:23 +00:00
$pw_peer_int = ifNameDescr ( $pw_peer_int );
echo ( " $br <img src='images/16/arrow_switch.png' align=absmiddle><b> " . generate_port_link ( $pw_peer_int , makeshortif ( $pw_peer_int [ 'label' ])) . " on " . generate_device_link ( $pw_peer_dev , shorthost ( $pw_peer_dev [ 'hostname' ])) . " </b> " );
$br = " <br /> " ;
}
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ? " , array ( $interface [ 'ifIndex' ], $device [ 'device_id' ])) as $member )
2011-03-17 11:29:23 +00:00
{
echo ( " $br <img src='images/16/brick_link.png' align=absmiddle> <strong> " . generate_port_link ( $member ) . " (PAgP)</strong> " );
$br = " <br /> " ;
}
if ( $interface [ 'pagpGroupIfIndex' ] && $interface [ 'pagpGroupIfIndex' ] != $interface [ 'ifIndex' ])
{
2011-05-12 22:14:56 +00:00
$parent = dbFetchRow ( " SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ? " , array ( $interface [ 'pagpGroupIfIndex' ], $device [ 'device_id' ]));
2011-03-17 11:29:23 +00:00
echo ( " $br <img src='images/16/bricks.png' align=absmiddle> <strong> " . generate_port_link ( $parent ) . " (PAgP)</strong> " );
$br = " <br /> " ;
}
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? and `device_id` = ? " , array ( $interface [ 'ifIndex' ], $device [ 'device_id' ])) as $higher_if )
2011-04-27 17:41:35 +00:00
{
if ( $higher_if [ 'interface_id_high' ])
{
2011-05-19 10:02:55 +00:00
$this_port = get_port_by_index_cache ( $device [ 'device_id' ], $higher_if [ 'interface_id_high' ]);
2011-04-27 17:41:35 +00:00
echo ( " $br <img src='images/16/arrow_divide.png' align=absmiddle> <strong> " . generate_port_link ( $this_port ) . " </strong> " );
$br = " <br /> " ;
}
}
2011-05-12 22:14:56 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `ports_stack` WHERE `interface_id_high` = ? and `device_id` = ? " , array ( $interface [ 'ifIndex' ], $device [ 'device_id' ])) as $lower_if )
2011-04-27 17:41:35 +00:00
{
if ( $lower_if [ 'interface_id_low' ])
{
2011-05-19 10:02:55 +00:00
$this_port = get_port_by_index_cache ( $device [ 'device_id' ], $lower_if [ 'interface_id_low' ]);
2011-04-27 17:41:35 +00:00
echo ( " $br <img src='images/16/arrow_join.png' align=absmiddle> <strong> " . generate_port_link ( $this_port ) . " </strong> " );
$br = " <br /> " ;
}
}
2011-05-19 10:02:55 +00:00
2011-03-17 11:29:23 +00:00
unset ( $int_links , $int_links_v6 , $int_links_v4 , $int_links_phys , $br );
echo ( " </td></tr> " );
// If we're showing graphs, generate the graph and print the img tags
if ( $graph_type == " etherlike " )
{
$graph_file = $config [ 'rrd_dir' ] . " / " . $device [ 'hostname' ] . " /port- " . safename ( $interface [ 'ifIndex' ]) . " -dot3.rrd " ;
} else {
$graph_file = $config [ 'rrd_dir' ] . " / " . $device [ 'hostname' ] . " /port- " . safename ( $interface [ 'ifIndex' ]) . " .rrd " ;
}
if ( $graph_type && is_file ( $graph_file ))
{
$type = $graph_type ;
2011-05-17 19:21:20 +00:00
echo ( " <tr style='background-color: $row_colour ; padding: 0px;'><td colspan=7> " );
2007-06-24 14:56:47 +00:00
2011-03-17 11:29:23 +00:00
include ( " includes/print-interface-graphs.inc.php " );
2010-08-01 14:17:06 +00:00
2007-06-24 14:56:47 +00:00
echo ( " </td></tr> " );
2011-03-17 11:29:23 +00:00
}
2007-04-03 14:10:23 +00:00
2011-04-24 01:54:30 +00:00
?>