From bf8782b8c0dd4abfa4eb1b0ecb3375797cb6d578 Mon Sep 17 00:00:00 2001
From: Manuel Ceroni <46685230+manuelceroni@users.noreply.github.com>
Date: Tue, 7 Oct 2025 18:56:38 +0200
Subject: [PATCH] Added a dropdown for selecting the SNMP Interface type
(#9727)
* Added a dropdown for selecting the SNMP Interface type
* Added port type column to the SNMP device interfaces table
---
httpdocs/tables_config/snmp_device_interfaces.json | 9 +++++++++
httpdocs/templates/dropdown_snmp_type.html | 10 ++++++++++
scripts/locales/en.lua | 13 +++++++++++++
scripts/lua/modules/http_lint.lua | 2 ++
4 files changed, 34 insertions(+)
create mode 100644 httpdocs/templates/dropdown_snmp_type.html
diff --git a/httpdocs/tables_config/snmp_device_interfaces.json b/httpdocs/tables_config/snmp_device_interfaces.json
index 5c007d656b..f3b1693eae 100644
--- a/httpdocs/tables_config/snmp_device_interfaces.json
+++ b/httpdocs/tables_config/snmp_device_interfaces.json
@@ -48,6 +48,15 @@
"text-nowrap"
]
},
+ {
+ "title_i18n": "snmp.interface_port_type",
+ "data_field": "port_type",
+ "min-width" : "100px",
+ "sortable": true,
+ "class": [
+ "text-nowrap"
+ ]
+ },
{
"title_i18n": "snmp.in_bytes",
"data_field": "in_bytes",
diff --git a/httpdocs/templates/dropdown_snmp_type.html b/httpdocs/templates/dropdown_snmp_type.html
new file mode 100644
index 0000000000..0959c68aa3
--- /dev/null
+++ b/httpdocs/templates/dropdown_snmp_type.html
@@ -0,0 +1,10 @@
+
+ {* icon or "" *}
+
+
diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua
index 60a3a06122..1b4e7c723c 100644
--- a/scripts/locales/en.lua
+++ b/scripts/locales/en.lua
@@ -7655,6 +7655,17 @@ local lang = {
["snmp"] = "SNMP",
["snmp_alerts"] = "SNMP Alerts",
["snmp_device_config"] = "Device Configuration",
+ ["snmp_interface_port_type_title"] = "Port Type",
+ ["snmp_interface_port_type_description"] = "SNMP interface port type",
+ ["snmp_interface_port_type_list"] = {
+ ["transit"] = "Transit",
+ ["ix"] = "IX (Internet Exchange)",
+ ["peering"] = "Peering",
+ ["customer_interface"] = "Customer Interface",
+ ["internet_connectivity"] = "Internet Connectivity (Uplink)",
+ ["internal_interface"]="Internal Interface (LAN)",
+ ["other"] = "Other",
+ },
["snmp_port_avg_usage_threshold_description"] = "Set a threshold to trigger alerts when the port percentage usage (in or out traffic) exceeds the specified limit (on a 5-min average).",
["snmp_port_avg_usage_threshold_title"] = "Interface Avg Usage Threshold",
["snmp_port_load_threshold_description"] = "Set a threshold (as percentage of the port speed) to trigger alerts when the port load exceeds the specified limit (on a 5-min average).",
@@ -8495,6 +8506,7 @@ local lang = {
["interface_alias"] = "Interface Alias",
["interface_device"] = "Interface %{interface} [ %{device} ]",
["interface_device_2"] = "%{interface}",
+ ["interface_port_type"] = "Port Type",
["interface_similarity"] = "Interface Similarity",
["interfaces_with_discards"] = "Interfaces With Discards",
["interfaces_with_errors"] = "Interfaces With Errors",
@@ -8534,6 +8546,7 @@ local lang = {
["ping_devices"] = "Ping Devices",
["port_macs"] = "MAC Addresses",
["port_macs_short"] = "MACs",
+ ["port_types"] = "Port Types",
["printer"] = "Printer",
["privacy_passphrase"] = "Privacy PassPhrase",
["privacy_protocol"] = "Privacy Protocol",
diff --git a/scripts/lua/modules/http_lint.lua b/scripts/lua/modules/http_lint.lua
index ce1eff767f..592bb9fbe9 100644
--- a/scripts/lua/modules/http_lint.lua
+++ b/scripts/lua/modules/http_lint.lua
@@ -2384,6 +2384,7 @@ local known_parameters = {
["toggle_snmp_qos_mib_polling"] = validateBool,
["toggle_snmp_alerts_port_status_change"] = validateBool,
["toggle_snmp_alerts_port_errors"] = validateBool,
+ ["snmp_interface_port_type_change"] = validateSingleWord,
["snmp_port_load_threshold"] = validateNumber,
["toggle_midnight_stats_reset"] = validateBool,
["toggle_ndpi_flows_rrds"] = validateBool,
@@ -2615,6 +2616,7 @@ local known_parameters = {
["snmp_admin_status"] = validateSNMPstatus, -- same as snmp_status but for the admin status
["snmp_if_type"] = validateNumber, -- snmp interface type (see snmp_utils.lua fnmp_iftype)
["iftype_filter"] = validateSingleWord, -- SNMP iftype filter name
+ ["port_type"] = validateSingleWord, -- SNMP Interface Port Type
["host_quota"] = validateEmptyOr(validateNumber), -- max traffi quota for host
["allowed_interface"] = validateEmptyOr(validateInterface), -- the interface an user is allowed to configure
["allowed_networks"] = validateNetworksList, -- a list of networks the user is allowed to monitor