Ad Widget

Collapse

Value should be a JSON object.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xrouted
    Junior Member
    • Jul 2016
    • 5

    #1

    Value should be a JSON object.

    Hello,

    my server is zabbix 3.0.4 installed on Debian 8. When i try to using the LLD external script as described here: https://share.zabbix.com/operating-s...-automatically ....

    I can't understand, why this makes a mistake, although I use Bash external script. The error is: Value should be a JSON object. ???

    Where I'm wrong?
    Attached Files
  • xrouted
    Junior Member
    • Jul 2016
    • 5

    #2
    And this is external script:


    Code:
    #!/bin/bash
    usage(){ echo "Usage: ./$(basename $0) hostname. For example:
    ./$(basename $0) server1.example.com";} if [ -z $1 ]; then usage; exit
    1; fi IFS=$'\n' LIST=$(nmap -T5 -F ${1} | grep 'open') echo -n
    '{"data":[' for s in $LIST; do
            PORT=$(echo $s | cut -d/ -f1)
            PROTO=$(echo $s | cut -d/ -f2 | awk '{sub(/[[:space:]].*/,"");
    print}')
            SERVICE=$(echo $s | awk '{print $3}')
            echo -n
    '{"{#PORT}":"'${PORT}'","{#PROTO}":"'${PROTO}'","{#SERVICE}":"'${SERVICE}'"},'
    done |sed -e 's:\},$:\}:' echo -n ']}'
    unset IFS

    Comment

    • FlorentCoppint
      Junior Member
      • Jun 2017
      • 2

      #3
      Hi,

      Having the exact same problem with the same script provided in Zabbix Share (https://share.zabbix.com/operating-s...-automatically).

      I checked that script run successful under zabbix user :

      Code:
      # su - zabbix -c "/usr/lib/zabbix/externalscripts/tcp-discovery.sh XX.YY.ZZZ.231" -s /bin/bash
      {"data":[{"{#PORT}":"21","{#PROTO}":"tcp","{#SERVICE}":"ftp"},{"{#PORT}":"80","{#PROTO}":"tcp","{#SERVICE}":"http"},{"{#PORT}":"443","{#PROTO}":"tcp","{#SERVICE}":"https"}]}
      Does someone have an idea ?

      Thank you

      Comment

      • FlorentCoppint
        Junior Member
        • Jun 2017
        • 2

        #4
        Ok I found the problem.
        I had a blank first line in my script. It was added by Ansible and {% raw %} usage.

        Comment

        Working...