From c5f2303778964046ab5ecc70d2f11a262addfb86 Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Fri, 27 Mar 2020 17:40:14 +0100 Subject: [PATCH] Fix bad SNMP interface formatter Fixes #3659 --- scripts/callbacks/system/snmp_device.lua | 7 ++++--- scripts/lua/modules/alerts_api.lua | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/callbacks/system/snmp_device.lua b/scripts/callbacks/system/snmp_device.lua index ca6ef1cfce19..db634e43aa50 100644 --- a/scripts/callbacks/system/snmp_device.lua +++ b/scripts/callbacks/system/snmp_device.lua @@ -90,14 +90,13 @@ local function snmp_device_run_user_scripts(snmp_device) -- For each interface of the current device... for snmp_interface_index, snmp_interface in pairs(device_interfaces) do local if_type = snmp_iftype(snmp_interface.type) - local do_call = true if(script.skip_virtual_interfaces and ((if_type == "propVirtual") or (if_type == "softwareLoopback"))) then - do_call = false + goto continue end - if(do_call and conf.enabled) then + if(conf.enabled) then local iface_entity = alerts_api.snmpInterfaceEntity(device_ip, snmp_interface_index) alerts_api.invokeScriptHook(script, confset_id, hook_fn, device_ip, snmp_interface_index, table.merge(snmp_interface, { @@ -108,6 +107,8 @@ local function snmp_device_run_user_scripts(snmp_device) now = now, })) end + + ::continue:: end end diff --git a/scripts/lua/modules/alerts_api.lua b/scripts/lua/modules/alerts_api.lua index 575978902cde..db7f46bfd009 100644 --- a/scripts/lua/modules/alerts_api.lua +++ b/scripts/lua/modules/alerts_api.lua @@ -426,7 +426,7 @@ end function alerts_api.snmpInterfaceEntity(snmp_device, snmp_interface) return { alert_entity = alert_consts.alert_entities.snmp_device, - alert_entity_val = string.format("%s_ifidx%d", snmp_device, snmp_interface) + alert_entity_val = string.format("%s_ifidx%s", snmp_device, ""..snmp_interface) } end