Optimized redis requests

This commit is contained in:
Matteo Biscosi 2025-10-08 17:30:03 +02:00
parent c6f49f7e4c
commit 24b5232546
2 changed files with 15 additions and 6 deletions

View file

@ -986,6 +986,7 @@ end
-- ##############################################
local _snmp_devices = {}
local _exporters_ports_names = {}
-- @brief This function format the SNMP interface name.
-- @params device_ip: snmp device ip
@ -1023,8 +1024,13 @@ function format_portidx_name(device_ip, portidx, short_version, interface_info)
-- No SNMP configured: last resort use exporters
local snmp_mappings = require "snmp_mappings"
local res = snmp_mappings.get_iface_name(device_ip, portidx)
if (res ~= nil) then idx_name = res end
local key = string.format("%s_%s", device_ip, portidx)
local port_name = _exporters_ports_names[key]
if (not port_name) then
port_name = snmp_mappings.get_iface_name(device_ip, portidx)
_exporters_ports_names[key] = port_name or ""
end
if (not isEmptyString(port_name)) then idx_name = port_name end
end
end