Added ability to set Probes aliases (#7599)

This commit is contained in:
Matteo Biscosi 2023-07-04 15:34:46 +00:00
parent 829c46cf84
commit fecac5de03
6 changed files with 126 additions and 0 deletions

View file

@ -109,7 +109,14 @@ end
function getProbeName(exporter_ip, show_vlan, shorten_len)
local cached_device_name
local snmp_cached_dev
local probe_alias = getFlowDevAlias(exporter_ip, true)
-- In case an alias is set to the flow exporter, directly use the alias
if not isEmptyString(probe_alias) and probe_alias ~= exporter_ip then
return probe_alias
end
-- No alias set, let's try with the SNMP
if ntop.isPro() then
snmp_cached_dev = require "snmp_cached_dev"
end
@ -1215,6 +1222,50 @@ end
-- ##############################################
function getFlowDevAliasKey()
return "ntopng.flow_dev_aliases"
end
-- ##############################################
function getFlowDevAlias(flowdev_ip, add_id)
local alias = ntop.getHashCache(getFlowDevAliasKey(), flowdev_ip)
local ret
if not isEmptyString(alias) then
if (add_id == true) then
ret = flowdev_ip .. " [" .. alias .. "]"
else
ret = alias
end
else
ret = tostring(flowdev_ip)
end
return ret
end
-- ##############################################
function getFullFlowDevName(flowdev_ip, compact, add_id)
local alias = getFlowDevAlias(flowdev_ip, add_id)
if not isEmptyString(flowdev_ip) then
if not isEmptyString(flowdev_ip) and alias ~= tostring(flowdev_ip) then
if compact then
alias = shortenString(alias)
return string.format("%s", alias)
else
return string.format("%s [%s]", flowdev_ip, alias)
end
end
end
return flowdev_ip
end
-- ##############################################
function getObsPointAliasKey()
return "ntopng.observation_point_aliases"
end