Files
PipoCanaja 53bfb24ef9 Migrate xDSL code to module, and add support for VDSL2 MIB (#14207)
* use component to discover if xDSL polling is needed

use component to discover if xDSL polling is needed

* Components OK, Polling in correct files, no DB for VDSL

* GUI

GUI_suite

* per port as well

* rename

* interface listing

* draytek_snmpsim

* fix arraymerge

fix names and max value

* schema

schema

style

* remove one dbFetchRows

remove 2x dbFetchCell

style

style

remove Legacy dbFetchRow

tests

tests

eloquent

more eloquent

more eloquent

one more gone

* fix properties access

eloquent_insert_update

style

tests

tests

tests

tests

* tests

tests

tests

* adslLineCoding

* Models

* fix not nullable cols in DB from code

default values

typo

rename

typo

schema

fix

fix

vdsl fix now

typo

typo

fix size

fix size

* Power values for VDSL

Power values for VDSL

Power values for VDSL

DB

* cleanup

* Rrd::checkRrdExists

* always enable DSL discovery

style

* xdsl module

* cleanup and move to Module

cleanup and move to Module

cleanup and move to Module

cleanup and move to Module

* Fix display

* fix polling and tenth

* remove legacy poller

* Style and Cosmetics

Cosmetics

Cleanup

* Translations

Translations

* exists

exists

* add test support for xdsl

* remove last component call

unused

* translations

* remove non standard onclick event on xdsl line

* Update Discovery Support.md

Update Poller Support.md

toner_gone

* Notification for removal of lnms config:set enable_ports_adsl true

* enable on devices with potential DSL interfaces

* tests are working now

fix teldat tests

* os_schema

* teldat

* move to new module structure

* move to new module structure

* wrong dump function

* wrong dump function

* laravel_through_key hidden

* Update notifications.rss

* Update notifications.rss

Co-authored-by: Tony Murray <murraytony@gmail.com>
2022-09-07 19:29:17 -05:00

266 lines
9.2 KiB
PHP

<?php
use App\Models\Device;
use App\Models\Port;
use App\Models\PortAdsl;
use App\Models\PortVdsl;
use App\Plugins\Hooks\PortTabHook;
use LibreNMS\Util\Rewrite;
use LibreNMS\Util\Url;
$vars['view'] = basename($vars['view'] ?? 'graphs');
$port = \App\Models\Port::find($vars['port']);
$port_details = 1;
$hostname = $device['hostname'];
$ifname = $port->ifDescr;
$ifIndex = $port->ifIndex;
$speed = \LibreNMS\Util\Number::formatSi($port->ifSpeed, 2, 3, 'bps');
$ifalias = $port->getLabel();
if ($port->ifPhysAddress) {
$mac = $port->ifPhysAddress;
}
$color = 'black';
if ($port->ifAdminStatus == 'down') {
$status = "<span class='grey'>Disabled</span>";
}
if ($port->ifAdminStatus == 'up' && $port->ifOperStatus != 'up') {
$status = "<span class='red'>Enabled / Disconnected</span>";
}
if ($port->ifAdminStatus == 'up' && $port->ifOperStatus == 'up') {
$status = "<span class='green'>Enabled / Connected</span>";
}
$i = 1;
$inf = Rewrite::normalizeIfName($ifname);
$bg = '#ffffff';
$show_all = 1;
echo "<div class=ifcell style='margin: 0px;'><table width=100% cellpadding=10 cellspacing=0>";
require 'includes/html/print-interface.inc.php';
echo '</table></div>';
$pos = strpos(strtolower($ifname), 'vlan');
if ($pos !== false) {
$broke = 'yes';
}
$pos = strpos(strtolower($ifname), 'loopback');
if ($pos !== false) {
$broke = 'yes';
}
echo "<div style='clear: both;'>";
print_optionbar_start();
$link_array = [
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'port',
'port' => $port->port_id,
];
$menu_options['graphs'] = 'Graphs';
$menu_options['realtime'] = 'Real time';
// FIXME CONDITIONAL
$menu_options['arp'] = 'ARP Table';
$menu_options['fdb'] = 'FDB Table';
$menu_options['events'] = 'Eventlog';
$menu_options['notes'] = 'Notes';
if (dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND entPhysicalIndex_measured = 'ports'", [$device['device_id'], $port->ifIndex])) {
$menu_options['sensors'] = 'Health';
}
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';
}
if (DeviceCache::getPrimary()->ports()->where('pagpGroupIfIndex', $port->ifIndex)->exists()) {
$menu_options['pagp'] = 'PAgP';
}
if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '" . $port->port_id . "' and `device_id` = '" . $device['device_id'] . "'")) {
$menu_options['vlans'] = 'VLANs';
}
// Are there any CBQoS components for this device?
$component = new LibreNMS\Component();
$options = []; // Re-init array in case it has been declared previously.
$options['filter']['type'] = ['=', 'Cisco-CBQOS'];
$components = $component->getComponents($device['device_id'], $options);
$components = $components[$device['device_id']] ?? []; // We only care about our device id.
if (count($components) > 0) {
$menu_options['cbqos'] = 'CBQoS';
}
$portModel = Port::find($port->port_id);
if (LibreNMS\Plugins::countHooks('port_container') || \PluginManager::hasHooks(PortTabHook::class, ['port' => $portModel])) {
// Checking if any plugin implements the port_container. If yes, allow to display the menu_option
$menu_options['plugins'] = 'Plugins';
}
$sep = '';
foreach ($menu_options as $option => $text) {
echo $sep;
if ($vars['view'] == $option) {
echo "<span class='pagemenu-selected'>";
}
echo generate_link($text, $link_array, ['view' => $option]);
if ($vars['view'] == $option) {
echo '</span>';
}
$sep = ' | ';
}
unset($sep);
if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '" . $port->port_id . "'") > '0') {
echo generate_link($descr, $link_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, ['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, ['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, ['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, ['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, ['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, ['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'>";
}
echo "<a href='" . Url::generate(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port->port_id]) . "/junose-atm-vp/bits/'>Bits</a>";
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'>";
}
echo "<a href='" . Url::generate(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port->port_id]) . "/junose-atm-vp/packets/'>Packets</a>";
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'>";
}
echo "<a href='" . Url::generate(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port->port_id]) . "/junose-atm-vp/cells/'>Cells</a>";
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'>";
}
echo "<a href='" . Url::generate(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port->port_id]) . "/junose-atm-vp/errors/'>Errors</a>";
if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') {
echo '</span>';
}
}//end if
if (Auth::user()->hasGlobalAdmin() && \LibreNMS\Config::get('enable_billing') == 1) {
$bills = dbFetchRows('SELECT `bill_id` FROM `bill_ports` WHERE `port_id`=?', [$port->port_id]);
if (count($bills) === 1) {
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>";
} elseif (count($bills) > 1) {
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>";
} else {
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>";
}
}
print_optionbar_end();
echo "<div style='margin: 5px;'>";
require 'includes/html/pages/device/port/' . $vars['view'] . '.inc.php';
echo '</div>';