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

Self-written sender in bash - Header length

XMLWordPrintable

    • Icon: Documentation task Documentation task
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • 4.0.7
    • Server (S)
    • None
    • CentOS Linux release 7.4.1708 (Core)
      3.10.0-693.17.1.el7.x86_64 GNU/Linux
    • Sprint 52 (May 2019)

      We're using self-written senders on some dedicated systems. As described in 4 Header we used the example with bash. Sending is done by nc (netcat).

      example.sh
      DATA='{ "request":"sender data", "data":[ { "host":"host1", "key":"test.item[1]", "value":"0"}] }'
      printf -v LENGTH '%016x' "${#DATA}"
      PACK=""
      for i in {14..0..-2}; do PACK="$PACK\\x${LENGTH:$i:2}"; done
      printf "ZBXD\1$PACK%s" $DATA | \
              nc -v -s 127.0.0.1 127.0.0.1 10051
      

      Executing the code:

      # ./example.sh
      Ncat: Version 6.40 ( http://nmap.org/ncat )
      Ncat: Connected to 127.0.0.1:10051.
      Ncat: 218 bytes sent, 0 bytes received in 0.01 seconds.
      

      Zabbix server log says:

      zabbix_server.log
      Message from 127.0.0.1 is longer than expected 109 bytes. Message ignored.
      

      For some reason the header length is calculated wrong in my example.sh.

      Executing the script without nc prints this:

      ZBXDm{ZBXDm"request":"senderZBXDmdata",ZBXDm"data":[ZBXDm{ZBXDm"host":"host1",ZBXDm"key":"test.item[1]",ZBXDm"value":"0"}]ZBXDm}
      

            vso Vladislavs Sokurenko
            Birchler Dominique
            Team A
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: