2007-04-03 14:10:23 +00:00
< ? php
# This file prints a table row for each interface
2007-06-24 14:56:47 +00:00
$interface [ 'device_id' ] = $device [ 'device_id' ];
$interface [ 'hostname' ] = $device [ 'hostname' ];
if ( ! $_GET [ 'type' ]) { $_GET [ 'type' ] = " bits " ; }
2007-04-07 21:15:23 +00:00
$if_id = $interface [ 'interface_id' ];
2008-11-05 15:24:44 +00:00
2007-04-07 21:15:23 +00:00
$ifDescr = fixifName ( $interface [ 'ifDescr' ]);
2007-04-03 14:10:23 +00:00
$ifIndex = $interface [ 'ifIndex' ];
2007-04-07 21:15:23 +00:00
$ifAlias = $interface [ 'ifAlias' ];
$ifSpeed = humanspeed ( $interface [ 'ifSpeed' ]);
$ifPhysAddress = $interface [ 'ifPhysAddress' ];
$ifType = fixiftype ( $interface [ 'ifType' ]);
2007-04-09 01:01:48 +00:00
$ifHardType = $interface [ 'ifHardType' ];
2007-06-24 14:56:47 +00:00
2007-04-07 21:15:23 +00:00
if ( $ifAlias ) { $ifAlias = $ifAlias . " </br> " ;}
2007-04-03 14:10:23 +00:00
if ( $bg == " #ffffff " ) { $bg = " #e5e5e5 " ; } else { $bg = " #ffffff " ; }
2007-04-07 21:15:23 +00:00
2007-06-24 14:56:47 +00:00
if ( $interface [ 'in_errors' ] > 0 || $interface [ 'out_errors' ] > 0 ) {
2008-03-12 19:50:05 +00:00
$error_img = generateiflink ( $interface , " <img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0> " , errors );
2007-06-24 14:56:47 +00:00
} else { $error_img = " " ; }
2008-11-05 15:24:44 +00:00
# $graph_url = "graph.php?if=$if_id&from=$twoday&to=$now&width=400&height=120&type=bits";
2007-04-07 21:15:23 +00:00
2008-10-28 18:25:53 +00:00
2009-03-20 13:25:19 +00:00
echo ( " <tr style= \" background-color: $bg ; padding: 5px; \" valign=top onmouseover= \" this.style.backgroundColor='#fdd'; \" onmouseout= \" this.style.backgroundColor=' $bg '; \" onclick= \" location.href='/device/ " . $device [ 'device_id' ] . " /' \" style='cursor: hand;'>
2008-10-28 18:25:53 +00:00
< td valign = top width = 300 > " );
echo ( " <span class=list-large>
2007-06-24 14:56:47 +00:00
" . generateiflink( $interface , " $i . $ifDescr " ) . " $error_img
2008-11-05 15:24:44 +00:00
</ span >< br />< span class = interface - desc > $ifAlias </ span > " );
2008-03-31 13:08:17 +00:00
2008-10-28 18:25:53 +00:00
if ( $ifAlias ) { echo ( " <br /> " ); }
2008-03-31 13:08:17 +00:00
2007-04-03 14:10:23 +00:00
unset ( $break );
if ( ! $dographs ) {
2007-04-09 01:01:48 +00:00
$ipdata = mysql_query ( " SELECT * FROM `ipaddr` WHERE `interface_id` = ' " . $interface [ 'interface_id' ] . " ' " );
2007-04-03 14:10:23 +00:00
while ( $ip = mysql_fetch_Array ( $ipdata )) {
echo ( " $break <a class=interface-desc href= \" javascript:popUp('/netcmd.php?cmd=whois&query= $ip[addr] ') \" > $ip[addr] / $ip[cidr] </a> " );
2008-03-31 13:08:17 +00:00
$break = " <br /> " ;
2008-04-13 16:27:05 +00:00
}
$ip6data = mysql_query ( " SELECT * FROM `ip6addr` WHERE `interface_id` = ' " . $interface [ 'interface_id' ] . " ' " );
while ( $ip6 = mysql_fetch_Array ( $ip6data )) {
echo ( " $break <a class=interface-desc href= \" javascript:popUp('/netcmd.php?cmd=whois&query= $ip6[addr] ') \" > " . Net_IPv6 :: compress ( $ip6 [ addr ]) . " / $ip6[cidr] </a> " );
$break = " <br /> " ;
}
2007-04-03 14:10:23 +00:00
echo ( " </span> " );
2009-02-02 15:38:34 +00:00
echo ( " </td><td width=100> " );
if ( mysql_result ( mysql_query ( " SELECT count(*) FROM mac_accounting WHERE interface_id = ' " . $interface [ 'interface_id' ] . " ' " ), 0 )){
echo ( " <a href='/?page=mac-accounting&id= " . $interface [ 'interface_id' ] . " '><img src='/images/16/chart_curve.png' align='absmiddle'> Mac Acc</a> " );
}
2008-09-25 13:54:58 +00:00
echo ( " </td><td width=120> " );
2007-06-24 14:56:47 +00:00
if ( $interface [ 'ifOperStatus' ] == " up " ) {
2007-06-24 16:45:18 +00:00
$in_perc = @ round ( $interface [ 'in_rate' ] / $interface [ 'ifSpeed' ] * 100 );
$out_perc = @ round ( $interface [ 'in_rate' ] / $interface [ 'ifSpeed' ] * 100 );
2007-06-24 14:56:47 +00:00
2008-03-12 19:50:05 +00:00
echo ( " <img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour ( $in_perc ) . " '> " .
2007-12-03 16:56:58 +00:00
formatRates ( $interface [ 'in_rate' ]) . " </span><br /> " );
2008-03-12 19:50:05 +00:00
echo ( " <img align=absmiddle src='images/16/arrow_out.png'> <span style='color: " . percent_colour ( $out_perc ) . " '> " .
2007-12-03 16:56:58 +00:00
formatRates ( $interface [ 'out_rate' ]) . " </span> " );
2007-06-24 14:56:47 +00:00
}
2009-03-02 18:12:09 +00:00
echo ( " </td><td width=75Barbuda> " );
2007-04-07 21:15:23 +00:00
if ( $ifSpeed && $ifSpeed != " " ) { echo ( " <span class=box-desc> $ifSpeed </span> " ); }
2007-04-09 01:01:48 +00:00
echo ( " <br /> " );
2007-04-15 14:38:26 +00:00
# if($interface[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
2009-03-02 18:12:09 +00:00
if ( $device [ 'os' ] == " IOS " || $device [ 'os' ] == " IOS XE " ) {
2007-04-15 14:38:26 +00:00
2009-03-02 18:12:09 +00:00
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> " );
2008-10-28 22:06:00 +00:00
} elseif ( $interface [ 'ifVrf' ]) {
$vrf = mysql_fetch_array ( mysql_query ( " SELECT * FROM vrfs WHERE vrf_id = ' " . $interface [ 'ifVrf' ] . " ' " ));
echo ( " <span style='color: green;'> " . $vrf [ 'vrf_name' ] . " </span> " );
2009-03-02 18:12:09 +00:00
}
2007-04-15 14:38:26 +00:00
}
2007-04-09 01:01:48 +00:00
echo ( " </td><td width=150> " );
if ( $ifType && $ifType != " " ) { echo ( " <span class=box-desc> " . $ifType . " </span> " ); } else { echo ( " - " ); }
echo ( " <br /> " );
if ( $ifHardType && $ifHardType != " " ) { echo ( " <span class=box-desc> " . $ifHardType . " </span> " ); } else { echo ( " - " ); }
2007-04-07 19:25:55 +00:00
echo ( " </td><td width=150> " );
2007-04-07 21:15:23 +00:00
if ( $interface [ 'ifPhysAddress' ] && $interface [ 'ifPhysAddress' ] != " " ) { echo ( " <span class=box-desc> " . $interface [ 'ifPhysAddress' ] . " </span> " ); } else { echo ( " - " ); }
2007-04-09 01:01:48 +00:00
echo ( " <br /> " );
2007-04-07 21:15:23 +00:00
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> " );
2008-03-22 13:30:33 +00:00
echo ( " <td width=375 valign=top class=interface-desc> " );
2007-04-07 21:15:23 +00:00
if ( strpos ( $ifDescr , " oopback " ) === false && ! $dographs ) {
2007-04-09 01:01:48 +00:00
$link_query = mysql_query ( " select * from links AS L, interfaces AS I, devices AS D WHERE L.src_if = ' $if_id ' AND L.dst_if = I.interface_id AND I.device_id = D.device_id " );
2007-04-03 14:10:23 +00:00
while ( $link = mysql_fetch_array ( $link_query )) {
2008-11-05 15:24:44 +00:00
# echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generateiflink($link, makeshortif($link['ifDescr'])) . " on " . generatedevicelink($link, shorthost($link['hostname'])) . "</a><br />");
2008-04-13 16:27:05 +00:00
# $br = "<br />";
$int_links [ $link [ 'interface_id' ]] = $link [ 'interface_id' ];
$int_links_phys [ $link [ 'interface_id' ]] = 1 ;
2007-04-03 14:10:23 +00:00
}
2008-04-13 16:27:05 +00:00
2007-04-03 14:10:23 +00:00
unset ( $br );
$adj_sql = " SELECT * FROM networks AS N, interfaces AS I, adjacencies AS A " ;
2007-04-07 21:15:23 +00:00
$adj_sql = $adj_sql . " WHERE I.interface_id = A.interface_id AND A.network_id = N.id " ;
$adj_sql = $adj_sql . " AND I.interface_id = ' $if_id ' " ;
2007-04-03 14:10:23 +00:00
$adj_query = mysql_query ( " $adj_sql " );
while ( $adjs = mysql_fetch_array ( $adj_query )) {
$network_id = $adjs [ 'network_id' ];
2007-04-09 01:05:37 +00:00
$newsql = " SELECT * FROM adjacencies AS A, networks as N, interfaces as I, devices as D " ;
$newsql = $newsql . " WHERE N.id = ' $network_id ' AND A.network_id = N.id AND I.interface_id = A.interface_id AND D.device_id = I.device_id " ;
2008-04-13 16:27:05 +00:00
$newsql = $newsql . " AND D.device_id != ' " . $device [ 'device_id' ] . " ' AND I.ifDescr NOT LIKE '%loopback%' GROUP BY D.device_id ORDER BY D.hostname " ;
2007-04-03 14:10:23 +00:00
$new_query = mysql_query ( $newsql );
while ( $new = mysql_fetch_array ( $new_query )) {
2008-04-13 16:27:05 +00:00
2007-04-09 01:05:37 +00:00
$this_ifid = $new [ 'interface_id' ];
$this_hostid = $new [ 'device_id' ];
2007-04-03 14:10:23 +00:00
$this_hostname = $new [ 'hostname' ];
2007-04-07 21:15:23 +00:00
$this_ifname = fixifName ( $new [ 'ifDescr' ]);
2007-04-03 14:10:23 +00:00
$wq = mysql_query ( " select count(*) FROM links WHERE dst_if = ' $this_ifid ' AND src_if = $if_id ; " );
2008-04-13 16:27:05 +00:00
$int_links [ $this_ifid ] = $this_ifid ;
$int_links_v4 [ $this_ifid ] = 1 ;
# if (@mysql_result($wq, 0) == '0' && $this_hostname != $hostname) {
# $graph_url = "graph.php?if=$this_ifid&from=$twoday&to=$now&width=400&height=120&type=bits'";
# echo("$br <img src='images/16/bullet_go.png' alt='Same Subnet' align=absmiddle />" . generateiflink($new, makeshortif($new['ifDescr'])) . " on " . generatedevicelink($new));
# $br = "<br />";
# }
2007-04-03 14:10:23 +00:00
}
}
unset ( $br );
2008-04-14 09:32:54 +00:00
# }
2008-04-13 16:27:05 +00:00
$sql = " SELECT network_id FROM ip6addr AS A, ip6networks AS N, interfaces AS I
WHERE A . interface_id = I . interface_id
AND A . network = N . cidr
AND I . interface_id = '".$interface[' interface_id ']."' " ;
$nets_query = mysql_query ( $sql );
while ( $net = mysql_fetch_array ( $nets_query )) {
$network_id = $net [ 'network_id' ];
$sql = " SELECT I.interface_id FROM ip6addr AS A, ip6networks AS N, interfaces AS I, devices AS D
WHERE A . interface_id = I . interface_id
2008-04-14 09:32:54 +00:00
AND A . network = N . cidr AND N . network_id = '".$net[' network_id ']."' AND D . device_id = I . device_id
AND D . device_id != '".$device[' device_id ']."' AND A . origin != 'linklayer' AND A . origin != 'wellknown' " ;
2008-04-13 16:27:05 +00:00
$new_query = mysql_query ( $sql );
while ( $new = mysql_fetch_array ( $new_query )) {
echo ( $new [ 'network_id' ]);
$this_ifid = $new [ 'interface_id' ];
$this_hostid = $new [ 'device_id' ];
$this_hostname = $new [ 'hostname' ];
$this_ifname = fixifName ( $new [ 'ifDescr' ]);
$int_links [ $this_ifid ] = $this_ifid ;
$int_links_v6 [ $this_ifid ] = 1 ;
}
}
foreach ( $int_links as $int_link ) {
2008-11-05 15:24:44 +00:00
$link_if = mysql_fetch_array ( mysql_query ( " SELECT * from interfaces AS I, devices AS D WHERE I.device_id = D.device_id and I.interface_id = ' " . $int_link . " ' " ));
2008-04-13 16:27:05 +00:00
echo ( " $br " );
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'> " ); }
2008-11-05 15:24:44 +00:00
echo ( " <b> " . generateiflink ( $link_if , makeshortif ( $link_if [ 'ifDescr' ])) . " on " . generatedevicelink ( $link_if , shorthost ( $link_if [ 'hostname' ])) );
2008-04-13 16:27:05 +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 );
2008-04-14 09:32:54 +00:00
}
2008-10-28 18:25:53 +00:00
$pseudowires = mysql_query ( " SELECT * FROM `pseudowires` WHERE `interface_id` = ' " . $interface [ 'interface_id' ] . " ' " );
while ( $pseudowire = mysql_fetch_array ( $pseudowires )) {
#`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`
$pw_peer_dev = mysql_fetch_array ( mysql_query ( " SELECT * from `devices` WHERE `device_id` = ' " . $pseudowire [ 'peer_device_id' ] . " ' " ));
$pw_peer_int = mysql_fetch_array ( mysql_query ( " SELECT * from `interfaces` AS I, pseudowires AS P WHERE I.device_id = ' " . $pseudowire [ 'peer_device_id' ] . " ' AND
P . cpwVcID = '".$pseudowire[' cpwVcID ']."' AND
P . interface_id = I . interface_id " ));
2008-11-05 15:24:44 +00:00
echo ( " <img src='images/16/arrow_switch.png' align=absmiddle><b> " . generateiflink ( $pw_peer_int , makeshortif ( $pw_peer_int [ 'ifDescr' ])) . " on " . generatedevicelink ( $pw_peer_dev , shorthost ( $pw_peer_dev [ 'hostname' ])) . " </b> " );
2008-10-28 18:25:53 +00:00
}
2007-04-03 14:10:23 +00:00
echo ( " </td></tr> " );
// If we're showing graphs, generate the graph and print the img tags
2009-03-16 15:19:44 +00:00
if ( $dographs && is_file ( $config [ 'rrd_dir' ] . " / " . $hostname . " / " . $ifIndex . " .rrd " )) {
2007-06-24 14:56:47 +00:00
2007-11-21 14:26:24 +00:00
$type = $_GET [ 'type' ];
2007-06-24 14:56:47 +00:00
$daily_traffic = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $day &to= $now &width=210&height=100 " ;
$daily_url = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $day &to= $now &width=500&height=150 " ;
$weekly_traffic = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $week &to= $now &width=210&height=100 " ;
$weekly_url = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $week &to= $now &width=500&height=150 " ;
$monthly_traffic = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $month &to= $now &width=210&height=100 " ;
$monthly_url = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $month &to= $now &width=500&height=150 " ;
$yearly_traffic = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $year &to= $now &width=210&height=100 " ;
$yearly_url = " graph.php?if= $if_id &type= " . $_GET [ 'type' ] . " &from= $year &to= $now &width=500&height=150 " ;
echo ( " <tr style='background-color: $bg ; padding: 5px;'><td colspan=3> " );
2007-11-21 14:26:24 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'interface_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $daily_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " ); \"
2007-06-24 14:56:47 +00:00
onmouseout = \ " return nd(); \" > <img src=' $daily_traffic ' border=0></a> " );
2007-11-21 14:26:24 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'interface_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $weekly_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " ); \"
2007-06-24 14:56:47 +00:00
onmouseout = \ " return nd(); \" > <img src=' $weekly_traffic ' border=0></a> " );
2007-11-21 14:26:24 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'interface_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $monthly_url\ '>', LEFT, WIDTH, 350 " . $config [ 'overlib_defaults' ] . " ); \"
2007-06-24 14:56:47 +00:00
onmouseout = \ " return nd(); \" > <img src=' $monthly_traffic ' border=0></a> " );
2007-11-21 14:26:24 +00:00
echo ( " <a href='?page=interface&id= " . $interface [ 'interface_id' ] . " ' onmouseover= \" return overlib('<img src= \ ' $yearly_url\ '>', LEFT, WIDTH, 350 " . $config [ 'overlib_defaults' ] . " ); \"
2007-06-24 14:56:47 +00:00
onmouseout = \ " return nd(); \" > <img src=' $yearly_traffic ' border=0></a> " );
echo ( " </td></tr> " );
2007-04-03 14:10:23 +00:00
}
$i ++ ;
?>