Incorrect preprocessing behavior in Script item

XMLWordPrintable

    • Type: Problem report
    • Resolution: Declined
    • Priority: Trivial
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      Operation system : EulerOS
      Zabbix Version : 6.4.1

      I created a template to collect all port aliases in a monitoring item, and then added some hosts for testing.

      I found that some hosts are experiencing error issues(could not convert return value to utf8)

      This is the monitoring item I created

      This is the specific JavaScript preprocessing script:

      var resultMap = {};

      var elements = JSON.parse(value);
      var len = elements.length;
      for (i = 0; i < len; i++)

      Unknown macro: {   var element = elements[i];   var key = element['{#SNMPINDEX}

      '];
        var value = element'{#IFALIAS}';
        if (value.length === 0)

      Unknown macro: {     continue;   }

        resultMap[key] = value;
      }
      return JSON.stringify(resultMap);

      When I retrieve values from the host for testing, I receive error responses:

      It works fine when I test with 'raw data':

      .1.3.6.1.2.1.31.1.1.1.18.1 = STRING: UPTO-SCZIY-PB-IDC-YDDL4F-SW01                                   
      .1.3.6.1.2.1.31.1.1.1.18.2 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.3 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.4 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.5 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.6 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.7 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.8 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.9 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.10 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.11 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.12 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.13 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.14 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.15 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.16 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.17 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.18 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.19 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.20 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.21 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.22 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.23 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.24 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.25 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.26 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.27 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.28 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.29 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.30 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.31 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.32 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.33 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.34 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.35 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.36 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.37 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.38 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.39 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.40 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.41 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.42 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.43 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.44 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.45 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.46 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.47 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.48 = STRING: 
      .1.3.6.1.2.1.31.1.1.1.18.49 = STRING: TO-SCZIY-PA-IDC-YDDL4F-SW02                    
      .1.3.6.1.2.1.31.1.1.1.18.50 = STRING: TO-DDOS

      It consistently produces errors when executed automatically.

      Is there anyone who can help solve this issue? Thank you very much!

       

            Assignee:
            Zabbix Support Team
            Reporter:
            relaxyel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: