Added hiding of disabled ports in graph, device overview and device ports view. (#9017)

When disabling or ignoring ports in the "Ports Settings" (http://<nms_host>/device/device=<device_id>/tab=edit/section=ports/) then the ports are still shown under the Port tab for a specific device (http://<nms_host>/device/device=<device_id>/section=ports/) and in the Overall Traffic Graph.
To keep the view and graph more clear, this change only shows the ports which are not disabled or ignored.

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [y] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
Evil.2000
2018-08-17 19:24:11 +02:00
committed by Neil Lathwood
parent 7e3f91903e
commit 86c097574b
5 changed files with 9 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ $ds_out = 'OUTOCTETS';
$i = 1;
foreach ($devices as $device) {
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($device['device_id'])) as $int) {
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ? AND `disabled` = 0', array($device['device_id'])) as $int) {
$ignore = 0;
if (is_array($config['device_traffic_iftype'])) {
foreach ($config['device_traffic_iftype'] as $iftype) {

View File

@@ -14,8 +14,8 @@
<th data-column-id='ifName'>Name</th>
<th data-column-id='ifAdminStatus'>Admin</th>
<th data-column-id='ifOperStatus'>Oper</th>
<th data-column-id='disabled' data-sortable='false'>Disable</th>
<th data-column-id='ignore' data-sortable='false'>Ignore</th>
<th data-column-id='disabled' data-sortable='false'>Disable polling</th>
<th data-column-id='ignore' data-sortable='false'>Ignore alerts</th>
<th data-column-id='ifSpeed'>ifSpeed (bits/s)</th>
<th data-column-id='port_tune' data-sortable='false' data-searchable='false'>RRD Tune</th>
<th data-column-id='ifAlias'>Description</th>

View File

@@ -2,10 +2,10 @@
$overview = 1;
$ports['total'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($device['device_id']));
$ports['up'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifOperStatus` = 'up' AND `ifAdminStatus` = 'up'", array($device['device_id']));
$ports['down'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up'", array($device['device_id']));
$ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'down'", array($device['device_id']));
$ports['total'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `disabled` = 0", array($device['device_id']));
$ports['up'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifOperStatus` = 'up' AND `ifAdminStatus` = 'up' AND `disabled` = 0", array($device['device_id']));
$ports['down'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `disabled` = 0", array($device['device_id']));
$ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'down' AND `disabled` = 0", array($device['device_id']));
$services = get_service_status($device['device_id']);
$services['total'] = array_sum($services);

View File

@@ -59,7 +59,7 @@ if ($ports['total']) {
$ifsep = '';
foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) {
foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1' AND `disabled` = 0", array($device['device_id'])) as $data) {
$data = cleanPort($data);
$data = array_merge($data, $device);
echo "$ifsep".generate_port_link($data, makeshortif(strtolower($data['label'])));

View File

@@ -142,7 +142,7 @@ if ($vars['view'] == 'minigraphs') {
global $port_cache, $port_index_cache;
$ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id']));
$ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' AND `disabled` = 0 ORDER BY `ifIndex` ASC", array($device['device_id']));
// As we've dragged the whole database, lets pre-populate our caches :)
// FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries.