2009-09-07 11:07:59 +00:00
< ? php
2009-02-06 14:53:33 +00:00
2018-04-07 15:55:28 -05:00
use LibreNMS\Authentication\Auth ;
2015-07-13 20:10:26 +02:00
if ( ! isset ( $vars [ 'view' ])) {
$vars [ 'view' ] = 'graphs' ;
}
$port = dbFetchRow ( 'SELECT * FROM `ports` WHERE `port_id` = ?' , array ( $vars [ 'port' ]));
2011-03-16 23:10:10 +00:00
$port_details = 1 ;
2009-06-19 10:43:02 +00:00
2011-03-16 23:10:10 +00:00
$hostname = $device [ 'hostname' ];
2012-05-16 13:25:50 +00:00
$hostid = $device [ 'port_id' ];
2011-09-18 13:11:04 +00:00
$ifname = $port [ 'ifDescr' ];
2015-07-13 20:10:26 +02:00
$ifIndex = $port [ 'ifIndex' ];
$speed = humanspeed ( $port [ 'ifSpeed' ]);
2009-02-06 14:53:33 +00:00
2011-09-18 13:11:04 +00:00
$ifalias = $port [ 'name' ];
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
if ( $port [ 'ifPhysAddress' ]) {
$mac = " $port[ifPhysAddress] " ;
}
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
$color = 'black' ;
if ( $port [ 'ifAdminStatus' ] == 'down' ) {
$status = " <span class='grey'>Disabled</span> " ;
}
if ( $port [ 'ifAdminStatus' ] == 'up' && $port [ 'ifOperStatus' ] == 'down' ) {
$status = " <span class='red'>Enabled / Disconnected</span> " ;
}
if ( $port [ 'ifAdminStatus' ] == 'up' && $port [ 'ifOperStatus' ] == 'up' ) {
$status = " <span class='green'>Enabled / Connected</span> " ;
}
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
$i = 1 ;
2011-03-16 23:10:10 +00:00
$inf = fixifName ( $ifname );
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
$bg = '#ffffff' ;
2009-02-06 14:53:33 +00:00
2011-03-16 23:10:10 +00:00
$show_all = 1 ;
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
echo " <div class=ifcell style='margin: 0px;'><table width=100% cellpadding=10 cellspacing=0> " ;
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
require 'includes/print-interface.inc.php' ;
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
echo '</table></div>' ;
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
$pos = strpos ( strtolower ( $ifname ), 'vlan' );
if ( $pos !== false ) {
$broke = yes ;
2011-03-16 23:10:10 +00:00
}
2015-07-13 20:10:26 +02:00
$pos = strpos ( strtolower ( $ifname ), 'loopback' );
2011-03-16 23:10:10 +00:00
2015-07-13 20:10:26 +02:00
if ( $pos !== false ) {
$broke = yes ;
2011-03-16 23:10:10 +00:00
}
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
echo " <div style='clear: both;'> " ;
2009-02-06 14:53:33 +00:00
2010-01-13 23:56:33 +00:00
print_optionbar_start ();
2015-07-13 20:10:26 +02:00
$link_array = array (
'page' => 'device' ,
'device' => $device [ 'device_id' ],
'tab' => 'port' ,
'port' => $port [ 'port_id' ],
);
2011-09-08 02:57:02 +00:00
2011-09-18 13:11:04 +00:00
$menu_options [ 'graphs' ] = 'Graphs' ;
2015-07-13 20:10:26 +02:00
$menu_options [ 'realtime' ] = 'Real time' ;
// FIXME CONDITIONAL
$menu_options [ 'arp' ] = 'ARP Table' ;
2017-06-26 07:58:17 -05:00
$menu_options [ 'fdb' ] = 'FDB Table' ;
2015-07-13 20:10:26 +02:00
$menu_options [ 'events' ] = 'Eventlog' ;
2016-01-03 02:12:41 +01:00
$menu_options [ 'notes' ] = 'Notes' ;
2015-07-13 20:10:26 +02:00
2017-11-09 22:28:26 +01:00
if ( dbFetchCell ( " SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND entPhysicalIndex_measured = 'ports' " , array ( $device [ 'device_id' ], $port [ 'ifIndex' ]))) {
$menu_options [ 'sensors' ] = 'Health' ;
}
2015-07-13 20:10:26 +02:00
if ( dbFetchCell ( " SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ' " . $port [ 'port_id' ] . " ' " )) {
$menu_options [ 'adsl' ] = 'ADSL' ;
2011-04-09 16:04:04 +00:00
}
2015-07-13 20:10:26 +02:00
if ( dbFetchCell ( " SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = ' " . $port [ 'ifIndex' ] . " ' and `device_id` = ' " . $device [ 'device_id' ] . " ' " )) {
$menu_options [ 'pagp' ] = 'PAgP' ;
2011-03-16 23:10:10 +00:00
}
2009-05-11 13:43:59 +00:00
2015-07-13 20:10:26 +02:00
if ( dbFetchCell ( " SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = ' " . $port [ 'port_id' ] . " ' and `device_id` = ' " . $device [ 'device_id' ] . " ' " )) {
$menu_options [ 'vlans' ] = 'VLANs' ;
2011-03-16 23:10:10 +00:00
}
2009-10-28 13:49:37 +00:00
2016-02-23 16:52:37 +10:00
// Are there any CBQoS components for this device?
2016-08-21 08:07:14 -05:00
$component = new LibreNMS\Component ();
2016-02-23 16:52:37 +10:00
$options = array (); // Re-init array in case it has been declared previously.
$options [ 'filter' ][ 'type' ] = array ( '=' , 'Cisco-CBQOS' );
2016-08-18 20:28:22 -05:00
$components = $component -> getComponents ( $device [ 'device_id' ], $options );
2016-02-23 16:52:37 +10:00
$components = $components [ $device [ 'device_id' ]]; // We only care about our device id.
if ( count ( $components ) > 0 ) {
2016-01-21 21:18:14 +10:00
$menu_options [ 'cbqos' ] = 'CBQoS' ;
}
2018-05-22 09:11:27 +02:00
if ( LibreNMS\Plugins :: countHooks ( 'port_container' )) {
// Checking if any plugin implements the port_container. If yes, allow to display the menu_option
$menu_options [ 'plugins' ] = 'Plugins' ;
}
2015-07-13 20:10:26 +02:00
$sep = '' ;
foreach ( $menu_options as $option => $text ) {
echo $sep ;
if ( $vars [ 'view' ] == $option ) {
echo " <span class='pagemenu-selected'> " ;
}
echo generate_link ( $text , $link_array , array ( 'view' => $option ));
if ( $vars [ 'view' ] == $option ) {
echo '</span>' ;
}
$sep = ' | ' ;
2011-12-05 12:15:41 +00:00
}
2015-07-13 20:10:26 +02:00
unset ( $sep );
if ( dbFetchCell ( " SELECT count(*) FROM mac_accounting WHERE port_id = ' " . $port [ 'port_id' ] . " ' " ) > '0' ) {
echo generate_link ( $descr , $link_array , array ( 'view' => 'macaccounting' , 'graph' => $type ));
echo ' | Mac Accounting : ' ;
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'graphs' ) {
echo " <span class='pagemenu-selected'> " ;
}
echo generate_link ( 'Bits' , $link_array , array ( 'view' => 'macaccounting' , 'subview' => 'graphs' , 'graph' => 'bits' ));
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'graphs' ) {
echo '</span>' ;
}
echo '(' ;
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'minigraphs' ) {
echo " <span class='pagemenu-selected'> " ;
}
echo generate_link ( 'Mini' , $link_array , array ( 'view' => 'macaccounting' , 'subview' => 'minigraphs' , 'graph' => 'bits' ));
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'minigraphs' ) {
echo '</span>' ;
}
echo '|' ;
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'top10' ) {
echo " <span class='pagemenu-selected'> " ;
}
echo generate_link ( 'Top10' , $link_array , array ( 'view' => 'macaccounting' , 'subview' => 'top10' , 'graph' => 'bits' ));
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'top10' ) {
echo '</span>' ;
}
echo ') | ' ;
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'graphs' ) {
echo " <span class='pagemenu-selected'> " ;
}
echo generate_link ( 'Packets' , $link_array , array ( 'view' => 'macaccounting' , 'subview' => 'graphs' , 'graph' => 'pkts' ));
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'graphs' ) {
echo '</span>' ;
}
echo '(' ;
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'minigraphs' ) {
echo " <span class='pagemenu-selected'> " ;
}
echo generate_link ( 'Mini' , $link_array , array ( 'view' => 'macaccounting' , 'subview' => 'minigraphs' , 'graph' => 'pkts' ));
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'minigraphs' ) {
echo '</span>' ;
}
echo '|' ;
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'top10' ) {
echo " <span class='pagemenu-selected'> " ;
}
echo generate_link ( 'Top10' , $link_array , array ( 'view' => 'macaccounting' , 'subview' => 'top10' , 'graph' => 'pkts' ));
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'top10' ) {
echo '</span>' ;
}
echo ')' ;
} //end if
if ( dbFetchCell ( " SELECT COUNT(*) FROM juniAtmVp WHERE port_id = ' " . $port [ 'port_id' ] . " ' " ) > '0' ) {
// FIXME ATM VPs
// FIXME URLs BROKEN
echo ' | ATM VPs : ' ;
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo " <span class='pagemenu-selected'> " ;
}
2015-08-11 14:54:05 -07:00
echo " <a href=' " . generate_url ( array ( 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port [ 'port_id' ])) . " /junose-atm-vp/bits/'>Bits</a> " ;
2015-07-13 20:10:26 +02:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
}
echo ' | ' ;
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'packets' ) {
echo " <span class='pagemenu-selected'> " ;
}
2015-08-11 14:54:05 -07:00
echo " <a href=' " . generate_url ( array ( 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port [ 'port_id' ])) . " /junose-atm-vp/packets/'>Packets</a> " ;
2015-07-13 20:10:26 +02:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
}
echo ' | ' ;
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'cells' ) {
echo " <span class='pagemenu-selected'> " ;
}
2015-08-11 14:54:05 -07:00
echo " <a href=' " . generate_url ( array ( 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port [ 'port_id' ])) . " /junose-atm-vp/cells/'>Cells</a> " ;
2015-07-13 20:10:26 +02:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
}
echo ' | ' ;
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'errors' ) {
echo " <span class='pagemenu-selected'> " ;
}
2015-08-11 14:54:05 -07:00
echo " <a href=' " . generate_url ( array ( 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port [ 'port_id' ])) . " /junose-atm-vp/errors/'>Errors</a> " ;
2015-07-13 20:10:26 +02:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
}
} //end if
2018-04-07 15:55:28 -05:00
if ( Auth :: user () -> hasGlobalAdmin () && $config [ 'enable_billing' ] == 1 ) {
2017-01-29 13:27:08 +00:00
$bills = dbFetchRows ( " SELECT `bill_id` FROM `bill_ports` WHERE `port_id`=? " , array ( $port [ 'port_id' ]));
if ( count ( $bills ) === 1 ) {
echo " <span style='float: right;'><a href=' " . generate_url ( array ( 'page' => 'bill' , 'bill_id' => $bills [ 0 ][ 'bill_id' ])) . " '><i class='fa fa-money fa-lg icon-theme' aria-hidden='true'></i> View Bill</a></span> " ;
} elseif ( count ( $bills ) > 1 ) {
echo " <span style='float: right;'><a href=' " . generate_url ( array ( 'page' => 'bills' )) . " '><i class='fa fa-money fa-lg icon-theme' aria-hidden='true'></i> View Bills</a></span> " ;
} else {
echo " <span style='float: right;'><a href=' " . generate_url ( array ( 'page' => 'bills' , 'view' => 'add' , 'port' => $port [ 'port_id' ])) . " '><i class='fa fa-money fa-lg icon-theme' aria-hidden='true'></i> Create Bill</a></span> " ;
}
2015-07-13 20:10:26 +02:00
}
2009-02-06 14:53:33 +00:00
2015-07-13 20:10:26 +02:00
print_optionbar_end ();
2012-04-06 13:56:23 +00:00
2015-07-13 20:10:26 +02:00
echo " <div style='margin: 5px;'> " ;
2012-04-06 13:56:23 +00:00
2015-07-13 20:10:26 +02:00
require 'pages/device/port/' . mres ( $vars [ 'view' ]) . '.inc.php' ;
2011-03-16 23:10:10 +00:00
2015-07-13 20:10:26 +02:00
echo '</div>' ;