2009-09-07 11:07:59 +00:00
<? php
2009-02-06 14:53:33 +00:00
2022-09-08 02:29:17 +02:00
use App\Models\Device ;
use App\Models\Port ;
use App\Models\PortAdsl ;
use App\Models\PortVdsl ;
2021-10-19 13:53:28 +02:00
use App\Plugins\Hooks\PortTabHook ;
use LibreNMS\Util\Rewrite ;
use LibreNMS\Util\Url ;
2019-04-11 23:26:42 -05:00
$vars [ 'view' ] = basename ( $vars [ 'view' ] ?? 'graphs' );
2015-07-13 20:10:26 +02:00
2022-08-30 12:55:37 -05:00
$port = \App\Models\Port :: find ( $vars [ 'port' ]);
2015-07-13 20:10:26 +02:00
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' ];
2022-08-30 12:55:37 -05:00
$ifname = $port -> ifDescr ;
$ifIndex = $port -> ifIndex ;
$speed = \LibreNMS\Util\Number :: formatSi ( $port -> ifSpeed , 2 , 3 , 'bps' );
2009-02-06 14:53:33 +00:00
2022-08-30 12:55:37 -05:00
$ifalias = $port -> getLabel ();
2009-02-06 14:53:33 +00:00
2022-08-30 12:55:37 -05:00
if ( $port -> ifPhysAddress ) {
$mac = $port -> ifPhysAddress ;
2011-09-18 13:11:04 +00:00
}
2009-02-06 14:53:33 +00:00
2011-03-16 23:10:10 +00:00
$color = 'black' ;
2022-08-30 12:55:37 -05:00
if ( $port -> ifAdminStatus == 'down' ) {
2011-09-18 13:11:04 +00:00
$status = "<span class='grey'>Disabled</span>" ;
}
2015-07-13 20:10:26 +02:00
2022-08-30 12:55:37 -05:00
if ( $port -> ifAdminStatus == 'up' && $port -> ifOperStatus != 'up' ) {
2011-09-18 13:11:04 +00:00
$status = "<span class='red'>Enabled / Disconnected</span>" ;
}
2015-07-13 20:10:26 +02:00
2022-08-30 12:55:37 -05:00
if ( $port -> ifAdminStatus == 'up' && $port -> ifOperStatus == 'up' ) {
2011-09-18 13:11:04 +00:00
$status = "<span class='green'>Enabled / Connected</span>" ;
}
2009-02-06 14:53:33 +00:00
2011-03-16 23:10:10 +00:00
$i = 1 ;
2021-10-19 13:53:28 +02:00
$inf = Rewrite :: normalizeIfName ( $ifname );
2009-02-06 14:53:33 +00:00
2011-03-16 23:10:10 +00: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
2011-03-16 23:10:10 +00:00
echo "<div class=ifcell style='margin: 0px;'><table width=100% cellpadding=10 cellspacing=0>" ;
2009-02-06 14:53:33 +00:00
2019-04-11 23:26:42 -05:00
require 'includes/html/print-interface.inc.php' ;
2009-02-06 14:53:33 +00:00
2011-03-16 23:10:10 +00:00
echo '</table></div>' ;
2009-02-06 14:53:33 +00:00
2011-03-16 23:10:10 +00:00
$pos = strpos ( strtolower ( $ifname ), 'vlan' );
if ( $pos !== false ) {
2018-07-13 17:08:00 -05:00
$broke = 'yes' ;
2011-03-16 23:10:10 +00:00
}
$pos = strpos ( strtolower ( $ifname ), 'loopback' );
if ( $pos !== false ) {
2018-07-13 17:08:00 -05:00
$broke = 'yes' ;
2011-03-16 23:10:10 +00:00
}
2009-02-06 14:53:33 +00:00
echo "<div style='clear: both;'>" ;
2010-01-13 23:56:33 +00:00
print_optionbar_start ();
2011-09-18 13:11:04 +00:00
$link_array = [
'page' => 'device' ,
'device' => $device [ 'device_id' ],
'tab' => 'port' ,
2022-08-30 12:55:37 -05:00
'port' => $port -> port_id ,
2012-05-16 13:25:50 +00:00
];
2011-09-08 02:57:02 +00:00
2011-09-18 13:11:04 +00:00
$menu_options [ 'graphs' ] = 'Graphs' ;
2012-05-25 12:24:34 +00:00
$menu_options [ 'realtime' ] = 'Real time' ;
// FIXME CONDITIONAL
2011-09-18 13:11:04 +00:00
$menu_options [ 'arp' ] = 'ARP Table' ;
2017-06-26 07:58:17 -05:00
$menu_options [ 'fdb' ] = 'FDB Table' ;
2011-11-12 14:21:01 +00: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
2022-08-30 12:55:37 -05:00
if ( dbFetchCell ( "SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND entPhysicalIndex_measured = 'ports'" , [ $device [ 'device_id' ], $port -> ifIndex ])) {
2017-11-09 22:28:26 +01:00
$menu_options [ 'sensors' ] = 'Health' ;
}
2022-09-08 02:29:17 +02:00
if ( PortAdsl :: where ( 'port_id' , $port -> port_id ) -> exists ()) {
$menu_options [ 'xdsl' ] = 'xDSL' ;
} elseif ( PortVdsl :: where ( 'port_id' , $port -> port_id ) -> exists ()) {
$menu_options [ 'xdsl' ] = 'xDSL' ;
2011-04-09 16:04:04 +00:00
}
2022-09-08 02:29:17 +02:00
if ( DeviceCache :: getPrimary () -> ports () -> where ( 'pagpGroupIfIndex' , $port -> ifIndex ) -> exists ()) {
2011-09-18 13:11:04 +00:00
$menu_options [ 'pagp' ] = 'PAgP' ;
2011-03-16 23:10:10 +00:00
}
2009-05-11 13:43:59 +00:00
2022-08-30 12:55:37 -05:00
if ( dbFetchCell ( "SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '" . $port -> port_id . "' and `device_id` = '" . $device [ 'device_id' ] . "'" )) {
2011-09-18 13:11:04 +00:00
$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 = []; // Re-init array in case it has been declared previously.
$options [ 'filter' ][ 'type' ] = [ '=' , 'Cisco-CBQOS' ];
2016-08-18 20:28:22 -05:00
$components = $component -> getComponents ( $device [ 'device_id' ], $options );
2021-03-12 18:10:14 -06:00
$components = $components [ $device [ 'device_id' ]] ?? []; // We only care about our device id.
2016-02-23 16:52:37 +10:00
if ( count ( $components ) > 0 ) {
2016-01-21 21:18:14 +10:00
$menu_options [ 'cbqos' ] = 'CBQoS' ;
}
2022-09-08 02:29:17 +02:00
$portModel = Port :: find ( $port -> port_id );
2021-10-19 13:53:28 +02:00
if ( LibreNMS\Plugins :: countHooks ( 'port_container' ) || \PluginManager :: hasHooks ( PortTabHook :: class , [ 'port' => $portModel ])) {
2018-05-22 09:11:27 +02:00
// Checking if any plugin implements the port_container. If yes, allow to display the menu_option
$menu_options [ 'plugins' ] = 'Plugins' ;
}
2015-02-16 23:45:28 +00:00
$sep = '' ;
2011-09-18 13:11:04 +00:00
foreach ( $menu_options as $option => $text ) {
2015-02-16 23:45:28 +00:00
echo $sep ;
if ( $vars [ 'view' ] == $option ) {
2015-01-12 15:21:03 +00:00
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2015-01-12 15:21:03 +00:00
echo generate_link ( $text , $link_array , [ 'view' => $option ]);
if ( $vars [ 'view' ] == $option ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
2015-01-12 15:21:03 +00:00
$sep = ' | ' ;
2011-12-05 12:15:41 +00:00
}
2011-09-18 13:11:04 +00:00
unset ( $sep );
2015-07-13 20:10:26 +02:00
2022-08-30 12:55:37 -05:00
if ( dbFetchCell ( "SELECT count(*) FROM mac_accounting WHERE port_id = '" . $port -> port_id . "'" ) > '0' ) {
2011-09-18 13:11:04 +00:00
echo generate_link ( $descr , $link_array , [ 'view' => 'macaccounting' , 'graph' => $type ]);
2015-07-13 20:10:26 +02:00
2011-04-09 16:04:04 +00:00
echo ' | Mac Accounting : ' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'graphs' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2011-09-18 13:11:04 +00:00
echo generate_link ( 'Bits' , $link_array , [ 'view' => 'macaccounting' , 'subview' => 'graphs' , 'graph' => 'bits' ]);
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'graphs' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo '(' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'minigraphs' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2011-09-18 13:11:04 +00:00
echo generate_link ( 'Mini' , $link_array , [ 'view' => 'macaccounting' , 'subview' => 'minigraphs' , 'graph' => 'bits' ]);
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'minigraphs' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo '|' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'top10' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2010-03-11 21:58:50 +00:00
echo generate_link ( 'Top10' , $link_array , [ 'view' => 'macaccounting' , 'subview' => 'top10' , 'graph' => 'bits' ]);
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'bits' && $vars [ 'subview' ] == 'top10' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo ') | ' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'graphs' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2011-09-18 13:11:04 +00:00
echo generate_link ( 'Packets' , $link_array , [ 'view' => 'macaccounting' , 'subview' => 'graphs' , 'graph' => 'pkts' ]);
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'graphs' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo '(' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'minigraphs' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2011-09-18 13:11:04 +00:00
echo generate_link ( 'Mini' , $link_array , [ 'view' => 'macaccounting' , 'subview' => 'minigraphs' , 'graph' => 'pkts' ]);
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'minigraphs' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo '|' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'top10' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2011-09-18 13:11:04 +00:00
echo generate_link ( 'Top10' , $link_array , [ 'view' => 'macaccounting' , 'subview' => 'top10' , 'graph' => 'pkts' ]);
if ( $vars [ 'view' ] == 'macaccounting' && $vars [ 'graph' ] == 'pkts' && $vars [ 'subview' ] == 'top10' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo ')' ;
2010-03-11 21:58:50 +00:00
} //end if
2015-07-13 20:10:26 +02:00
2022-08-30 12:55:37 -05:00
if ( dbFetchCell ( "SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '" . $port -> port_id . "'" ) > '0' ) {
2012-05-25 12:24:34 +00:00
// FIXME ATM VPs
// FIXME URLs BROKEN
2011-04-09 16:04:04 +00:00
echo ' | ATM VPs : ' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2022-08-30 12:55:37 -05:00
echo "<a href='" . Url :: generate ([ 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port -> port_id ]) . "/junose-atm-vp/bits/'>Bits</a>" ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo ' | ' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'packets' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2022-08-30 12:55:37 -05:00
echo "<a href='" . Url :: generate ([ 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port -> port_id ]) . "/junose-atm-vp/packets/'>Packets</a>" ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo ' | ' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'cells' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2022-08-30 12:55:37 -05:00
echo "<a href='" . Url :: generate ([ 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port -> port_id ]) . "/junose-atm-vp/cells/'>Cells</a>" ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
echo ' | ' ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'errors' ) {
echo "<span class='pagemenu-selected'>" ;
2015-07-13 20:10:26 +02:00
}
2022-08-30 12:55:37 -05:00
echo "<a href='" . Url :: generate ([ 'page' => 'device' , 'device' => $device [ 'device_id' ], 'tab' => 'port' , 'port' => $port -> port_id ]) . "/junose-atm-vp/errors/'>Errors</a>" ;
2011-09-18 13:11:04 +00:00
if ( $vars [ 'view' ] == 'junose-atm-vp' && $vars [ 'graph' ] == 'bits' ) {
echo '</span>' ;
2015-07-13 20:10:26 +02:00
}
} //end if
2019-08-05 14:16:05 -05:00
if ( Auth :: user () -> hasGlobalAdmin () && \LibreNMS\Config :: get ( 'enable_billing' ) == 1 ) {
2022-08-30 12:55:37 -05:00
$bills = dbFetchRows ( 'SELECT `bill_id` FROM `bill_ports` WHERE `port_id`=?' , [ $port -> port_id ]);
2017-01-29 13:27:08 +00:00
if ( count ( $bills ) === 1 ) {
2021-10-19 13:53:28 +02:00
echo "<span style='float: right;'><a href='" . Url :: generate ([ '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>" ;
2017-01-29 13:27:08 +00:00
} elseif ( count ( $bills ) > 1 ) {
2021-10-19 13:53:28 +02:00
echo "<span style='float: right;'><a href='" . Url :: generate ([ 'page' => 'bills' ]) . "'><i class='fa fa-money fa-lg icon-theme' aria-hidden='true'></i> View Bills</a></span>" ;
2017-01-29 13:27:08 +00:00
} else {
2022-08-30 12:55:37 -05:00
echo "<span style='float: right;'><a href='" . Url :: generate ([ '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>" ;
2017-01-29 13:27:08 +00:00
}
2015-07-13 20:10:26 +02:00
}
2009-02-06 14:53:33 +00:00
2010-07-18 08:51:18 +00:00
print_optionbar_end ();
2012-04-06 13:56:23 +00:00
2011-09-18 13:11:04 +00:00
echo "<div style='margin: 5px;'>" ;
2012-04-06 13:56:23 +00:00
2019-04-11 23:26:42 -05:00
require 'includes/html/pages/device/port/' . $vars [ 'view' ] . '.inc.php' ;
2011-03-16 23:10:10 +00:00
2015-07-13 20:10:26 +02:00
echo '</div>' ;