概述

为了不耗尽内存(可能),Zabbix协议仅限于在一个连接中仅接受128MB。

实施

4 Header and data length

Overview

Header and data length are present in response and request messages between Zabbix components. It is required to determine the length of message.

  1. <HEADER> - "ZBXD\x01" (5 bytes)

Implementation

Here are code snippets showing how to add Zabbix protocol header to the data you want to send in order to obtain packet you should send to Zabbix so it is interpreted correctly.

LanguageCode
bash
  1. printf -v LENGTH ‘%016x ${#DATA}”
  2. PACK=””
  3. for i in {14..0..-2}; do PACK=”$PACK\x${LENGTH:$i:2}”; done
  4. printf ZBXD\1$PACK%s $DATA
Java
PHP
  1. $packet = ZBXD\1 . pack(‘P’, ($data)) . $data;
or
  1. $packet = ZBXD\1 . pack(‘V’, ($data)) . \0\0\0\0 . $data;
Perl
    or
    1. my $packet = ZBXD\1 . pack(‘V’, ($data)) . \0\0\0\0 . $data;
    Python