Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-12195

Script output is contaminated with log messages

XMLWordPrintable

    • Sprint 9, Sprint 10, Sprint 11, Sprint 12
    • 1

      Hello.

      • I have script:
        json_data.sh
        #!/bin/bash
        # Generate JSON data for zabbix
        # json_data.sh "field1 field2 ... fieldn" "data1 data2 ... datan"
        
        declare -i i
        fields=$1
        data=($2)
        json=""
        i=0
        while [ $i -lt ${#data[*]} ]; do
            row=""
            for f in $fields; do
                row+="\"{#$f}\":\"${data[$i]}\","
                i+=1
            done
            json+="{${row%,}},"
        done
        echo -e "{\"data\": [${json%,}]}"
        
      • Macros
        {$IPDESCR}="88.151.176.41 SKY 93.185.69.98 KTC1 93.185.69.102 KTC2"
      • Discovery rule:
        Type: External check
        Key: json_data.sh["IP DESCR", {$IPDESCR}]
        And i always have error Value should be a JSON object.

      for testing i create TEXT item with key json_test.sh["IP DESCR", {$IPDESCR}]
      ln -s json_data.sh json_test.sh
      In history i have

      2017-05-18 10:23:00 1153:20170518:072300.562 zbx_popen(): executing script
      {"data": [{"{#IP}":"88.151.176.41","{#DESCR}":"SKY"},{"{#IP}":"93.185.69.98","{#DESCR}":"KTC1"},{"{#IP}":"93.185.69.102","{#DESCR}":"KTC2"}]}
      

      So result is valid JSON object. But why i have this error?

            Unassigned Unassigned
            Kvantum Vladimir Kushnir
            Team C
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: