[ZBX-20516] LLD JS preprocessing fails, Network ports discovery, SAN NetApp FAS3220 Created: 2021 May 28  Updated: 2025 Apr 22

Status: READY TO DEVELOP
Project: ZABBIX BUGS AND ISSUES
Component/s: Templates (T)
Affects Version/s: None
Fix Version/s: 7.0.13rc1, 7.2.7rc1, 7.4.0rc1 (master)

Type: Incident report Priority: Minor
Reporter: Aigars Kadikis Assignee: Zabbix Integration Team
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-05-28-17-55-38-690.png    
Issue Links:
Duplicate
Sub-task
Team: Team INT
Sprint: Sprint 85 (Feb 2022), Sprint 86 (Mar 2022), Sprint 87 (Apr 2022), Sprint 88 (May 2022), Sprint 89 (Jun 2022), Sprint 90 (Jul 2022), Sprint 91 (Aug 2022), Sprint 92 (Sep 2022), Sprint 93 (Oct 2022), Sprint 94 (Nov 2022), Sprint 95 (Dec 2022), Sprint 96 (Jan 2023), Sprint 97 (Feb 2023), Sprint 98 (Mar 2023), Sprint 99 (Apr 2023), Sprint 100 (May 2023), Sprint 101 (Jun 2023), Sprint 102 (Jul 2023), Sprint 103 (Aug 2023), Sprint 104 (Sep 2023), Sprint 105 (Oct 2023), Sprint 106 (Nov 2023), Sprint 107 (Dec 2023), Sprint candidates, S2401
Story Points: 1

 Description   

The template available at:

https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/san/netapp_fas3220_snmp?at=refs%2Fheads%2Frelease%2F5.0

Has a discovery rule "Network ports discovery" with key:

discovery[{#IFNAME},1.3.6.1.4.1.789.1.22.2.1.2,{#NODE},1.3.6.1.4.1.789.1.22.2.1.1,{#TYPE},1.3.6.1.4.1.789.1.22.2.1.15,{#ROLE},1.3.6.1.4.1.789.1.22.2.1.3,{#IFDESCR},1.3.6.1.4.1.789.1.22.1.2.1.2]

The data reported back looks like:

[{
"{#SNMPINDEX}": "8.100.99.45.99.108.45.48.50.3.101.50.100",
"{#IFNAME}": "e2d",
"{#NODE}": "dc-cl-02",
"{#TYPE}": "0",
"{#ROLE}": "2"
}]

This data fails to go through the preprocessing inside discovery section:

var data = JSON.parse(value);
var descriptions = {};
var out = [];

data.forEach(function(elem) {
    if (elem["{#IFDESCR}"]) {
        var parts = elem["{#IFDESCR}"].split(":");
        var port = parts[parts.length-1].split(' ');
        descriptions[parts[0] + ':' + port[port.length-1]] = {
            "{#IFDESCR}": elem["{#IFDESCR}"],
            "{#SNMPINDEX}": elem["{#SNMPINDEX}"]
        }
    }
});

data.forEach(function(elem) {
    if (elem["{#IFNAME}"]) {
        var port = descriptions[elem["{#NODE}"] + ':' + elem["{#IFNAME}"]];

        elem["{#IFDESCR}"] = port["{#IFDESCR}"];
        elem["{#IFSNMPINDEX}"] = port["{#SNMPINDEX}"];


        switch(elem["{#TYPE}"]) {
            case '0':
                elem["{#TYPE}"] = 'physical';
                break;
            case '1':
                elem["{#TYPE}"] = 'if-group';
                break;
            case '2':
                elem["{#TYPE}"] = 'vlan';
                break;
            case '3':
                elem["{#TYPE}"] = 'undef';
                break;
        };
    
        out.push(elem);
    }
});

return JSON.stringify(out); 

It prints:

Preprocessing failed for: [{..."{#SNMPINDEX}": "8.100.99.45.99.108.45.48.49.3.97.48.97",..."{#IFNAME}": "a0a",..."{#NODE}":...
1. Failed: TypeError: cannot read property '{#IFDESCR}' of undefined
at [anon] (duktape.c:57260) internal
at [anon] (function:20) preventsyield
at forEach () native strict preventsyield
at [anon] (function:41) preventsyield



 Comments   
Comment by Vjaceslavs Bogdanovs [ 2021 Jul 28 ]

The template is not compatible with this device. Please create a ZBXNEXT if support for this device is needed.

Comment by Nii Apleh [ 2022 Nov 08 ]

SNMP is not returing the IFDESCR

You can comment out the following lines in the javascript:
// "{#IFDESCR}": elem"{#IFDESCR}",
// "{#SNMPINDEX}": elem"{#SNMPINDEX}"

Generated at Sat Apr 26 04:18:56 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.