Files

117 lines
5.1 KiB
PHP
Raw Permalink Normal View History

2010-07-18 11:38:38 +00:00
<?php
// This file prints a table row for each interface
2019-06-23 00:29:12 -05:00
use LibreNMS\Config;
use LibreNMS\Util\IP;
2011-09-18 13:11:04 +00:00
$port['device_id'] = $device['device_id'];
2020-09-21 15:40:17 +02:00
$port['hostname'] = $device['hostname'];
2010-07-18 11:38:38 +00:00
$if_id = $port['port_id'];
2010-07-18 11:38:38 +00:00
$port = cleanPort($port);
2010-07-18 11:38:38 +00:00
2020-09-21 15:40:17 +02:00
if (! is_integer($i / 2)) {
2019-06-23 00:29:12 -05:00
$row_colour = Config::get('list_colour.even');
2016-08-18 20:28:22 -05:00
} else {
2019-06-23 00:29:12 -05:00
$row_colour = Config::get('list_colour.odd');
}
if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) {
$error_img = generate_port_link($port, "<i class='fa fa-flag fa-lg' style='color:red' aria-hidden='true'></i>", 'port_errors');
2016-08-18 20:28:22 -05:00
} else {
$error_img = '';
}
2019-06-23 00:29:12 -05:00
echo "<tr style=\"background-color: $row_colour; padding: 5px;\" valign=top onmouseover=\"this.style.backgroundColor='" . Config::get('list_colour.highlight') . "';\" onmouseout=\"this.style.backgroundColor='$row_colour';\"
2020-09-21 15:40:17 +02:00
onclick=\"location.href='device/" . $device['device_id'] . '/port/' . $port['port_id'] . "/'\" style='cursor: pointer;'>
<td valign=top width=350>";
echo ' <span class=list-large>
2020-09-21 15:40:17 +02:00
' . generate_port_link($port, $port['ifIndex'] . '. ' . $port['label']) . '
</span><br /><span class=interface-desc>' . display($port['ifAlias']) . '</span>';
2010-07-18 11:38:38 +00:00
if ($port['ifAlias']) {
echo '<br />';
2011-05-01 17:26:06 +00:00
}
2010-07-18 11:38:38 +00:00
2019-06-23 00:29:12 -05:00
$break = '';
if ($port_details) {
2020-09-21 15:40:17 +02:00
foreach (dbFetchRows('SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?', [$port['port_id']]) as $ip) {
echo "$break <a class=interface-desc href=\"javascript:popUp('ajax/netcmd?cmd=whois&amp;query=" . $ip['ipv4_address'] . "')\">" . $ip['ipv4_address'] . '/' . $ip['ipv4_prefixlen'] . '</a>';
$break = ',';
}
2020-09-21 15:40:17 +02:00
foreach (dbFetchRows('SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?', [$port['port_id']]) as $ip6) {
echo "$break <a class=interface-desc href=\"javascript:popUp('ajax/netcmd?cmd=whois&amp;query=" . $ip6['ipv6_address'] . "')\">" . IP::parse($ip6['ipv6_address'], true) . '/' . $ip6['ipv6_prefixlen'] . '</a>';
$break = ',';
}
2011-03-28 10:39:55 +00:00
}
echo '</span>';
2020-09-21 15:40:17 +02:00
$width = '120';
$height = '40';
2019-06-23 00:29:12 -05:00
$from = Config::get('time.day');
echo '</td><td width=135>';
2020-09-21 15:40:17 +02:00
echo formatRates(($port['ifInOctets_rate'] * 8)) . " <i class='fa fa-arrows-v fa-lg icon-theme' aria-hidden='true'></i> " . formatRates(($port['ifOutOctets_rate'] * 8));
echo '<br />';
$port['graph_type'] = 'port_bits';
echo generate_port_link(
$port,
2019-06-23 00:29:12 -05:00
"<img src='graph.php?type=" . $port['graph_type'] . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . Config::get('time.now') . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>",
$port['graph_type']
);
echo '</td><td width=135>';
2020-09-21 15:40:17 +02:00
echo '' . formatRates($port['adslAturChanCurrTxRate']) . '/' . formatRates($port['adslAtucChanCurrTxRate']);
echo '<br />';
$port['graph_type'] = 'port_adsl_speed';
echo generate_port_link(
$port,
2019-06-23 00:29:12 -05:00
"<img src='graph.php?type=" . $port['graph_type'] . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . Config::get('time.now') . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>",
$port['graph_type']
);
echo '</td><td width=135>';
2020-09-21 15:40:17 +02:00
echo '' . formatRates($port['adslAturCurrAttainableRate']) . '/' . formatRates($port['adslAtucCurrAttainableRate']);
echo '<br />';
$port['graph_type'] = 'port_adsl_attainable';
echo generate_port_link(
$port,
2019-06-23 00:29:12 -05:00
"<img src='graph.php?type=" . $port['graph_type'] . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . Config::get('time.now') . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>",
$port['graph_type']
);
echo '</td><td width=135>';
2020-09-21 15:40:17 +02:00
echo '' . $port['adslAturCurrAtn'] . 'dB/' . $port['adslAtucCurrAtn'] . 'dB';
echo '<br />';
$port['graph_type'] = 'port_adsl_attenuation';
echo generate_port_link(
$port,
2019-06-23 00:29:12 -05:00
"<img src='graph.php?type=" . $port['graph_type'] . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . Config::get('time.now') . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>",
$port['graph_type']
);
echo '</td><td width=135>';
2020-09-21 15:40:17 +02:00
echo '' . $port['adslAturCurrSnrMgn'] . 'dB/' . $port['adslAtucCurrSnrMgn'] . 'dB';
echo '<br />';
$port['graph_type'] = 'port_adsl_snr';
echo generate_port_link(
$port,
2019-06-23 00:29:12 -05:00
"<img src='graph.php?type=" . $port['graph_type'] . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . Config::get('time.now') . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>",
$port['graph_type']
);
echo '</td><td width=135>';
2020-09-21 15:40:17 +02:00
echo '' . $port['adslAturCurrOutputPwr'] . 'dBm/' . $port['adslAtucCurrOutputPwr'] . 'dBm';
echo '<br />';
$port['graph_type'] = 'port_adsl_power';
echo generate_port_link(
$port,
2019-06-23 00:29:12 -05:00
"<img src='graph.php?type=" . $port['graph_type'] . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . Config::get('time.now') . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>",
$port['graph_type']
);
echo '</td>';