From 86c097574b55cfa4f850faa8b15d315b2a6aa1f7 Mon Sep 17 00:00:00 2001 From: "Evil.2000" Date: Fri, 17 Aug 2018 19:24:11 +0200 Subject: [PATCH] Added hiding of disabled ports in graph, device overview and device ports view. (#9017) When disabling or ignoring ports in the "Ports Settings" (http:///device/device=/tab=edit/section=ports/) then the ports are still shown under the Port tab for a specific device (http:///device/device=/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 `, i.e `./scripts/github-apply 5926` --- html/includes/graphs/location/bits.inc.php | 2 +- html/pages/device/edit/ports.inc.php | 4 ++-- html/pages/device/overview.inc.php | 8 ++++---- html/pages/device/overview/ports.inc.php | 2 +- html/pages/device/ports.inc.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/html/includes/graphs/location/bits.inc.php b/html/includes/graphs/location/bits.inc.php index c73000b91a..1238f118e5 100644 --- a/html/includes/graphs/location/bits.inc.php +++ b/html/includes/graphs/location/bits.inc.php @@ -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) { diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index e8180e707d..ae8385e133 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -14,8 +14,8 @@ Name Admin Oper - Disable - Ignore + Disable polling + Ignore alerts ifSpeed (bits/s) RRD Tune Description diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index 918852162c..df13ce29c3 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -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); diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 3c3b72e2d4..821973cdab 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -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']))); diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index 34cb875b7b..3b69d1d162 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -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.