On this page

zabbix_sender

ZABBIX_SENDER(1)            通用命令手册           ZABBIX_SENDER(1)

名称
       zabbix_sender - Zabbix 发送工具

概要
       zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s
       host -k key -o value
       zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] [-s
       host] [-T] [-N] [-r] -i input-file
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] -k key -o value
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] [-T] [-N] [-r] -i input-file
       zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s
       host --tls-connect cert --tls-ca-file CA-file [--tls-crl-file CRL-file]
       [--tls-server-cert-issuer cert-issuer] [--tls-server-cert-subject
       cert-subject] --tls-cert-file cert-file --tls-key-file key-file
       [--tls-cipher13 cipher-string] [--tls-cipher cipher-string] -k key -o
       value
       zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] [-s
       host] --tls-connect cert --tls-ca-file CA-file [--tls-crl-file
       CRL-file] [--tls-server-cert-issuer cert-issuer]
       [--tls-server-cert-subject cert-subject] --tls-cert-file cert-file
       --tls-key-file key-file [--tls-cipher13 cipher-string] [--tls-cipher
       cipher-string] [-T] [-N] [-r] -i input-file
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] --tls-connect cert --tls-ca-file CA-file
       [--tls-crl-file CRL-file] [--tls-server-cert-issuer cert-issuer]
       [--tls-server-cert-subject cert-subject] --tls-cert-file cert-file
       --tls-key-file key-file [--tls-cipher13 cipher-string] [--tls-cipher
       cipher-string] -k key -o value
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] --tls-connect cert --tls-ca-file CA-file
       [--tls-crl-file CRL-file] [--tls-server-cert-issuer cert-issuer]
       [--tls-server-cert-subject cert-subject] --tls-cert-file cert-file
       --tls-key-file key-file [--tls-cipher13 cipher-string] [--tls-cipher
       cipher-string] [-T] [-N] [-r] -i input-file
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] --tls-connect cert --tls-ca-file CA-file
       [--tls-crl-file CRL-file] [--tls-server-cert-issuer cert-issuer]
       [--tls-server-cert-subject cert-subject] --tls-cert-file cert-file
       --tls-key-file key-file [--tls-cipher13 cipher-string] [--tls-cipher
       cipher-string] -k key -o value
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] --tls-connect cert --tls-ca-file CA-file
       [--tls-crl-file CRL-file] [--tls-server-cert-issuer cert-issuer]
       [--tls-server-cert-subject cert-subject] --tls-cert-file cert-file
       --tls-key-file key-file [--tls-cipher13 cipher-string] [--tls-cipher
       cipher-string] [-T] [-N] [-r] -i input-file
       zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s
       host --tls-connect psk --tls-psk-identity PSK-identity --tls-psk-file
       PSK-file [--tls-cipher13 cipher-string] [--tls-cipher cipher-string] -k
       key -o value
       zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] [-s
       host] --tls-connect psk --tls-psk-identity PSK-identity --tls-psk-file
       PSK-file [--tls-cipher13 cipher-string] [--tls-cipher cipher-string]
       [-T] [-N] [-r] -i input-file
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] --tls-connect psk --tls-psk-identity PSK-iden‐
       tity --tls-psk-file PSK-file [--tls-cipher13 cipher-string] [--tls-ci‐
       pher cipher-string] -k key -o value
       zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
       [-t timeout] [-s host] --tls-connect psk --tls-psk-identity PSK-iden‐
       tity --tls-psk-file PSK-file [--tls-cipher13 cipher-string] [--tls-ci‐
       pher cipher-string] [-T] [-N] [-r] -i input-file
       zabbix_sender -h
       zabbix_sender -V

描述
       zabbix_sender 是一个命令行工具,用于向 Zabbix 服务器 或 proxy 发送监控数据。
       在 Zabbix 服务器 上,应创建一个类型为 Zabbix trapper 的监控项,并配置相应的键值。
       请注意,只有来自此监控项“Allowed hosts”字段中指定主机的传入值才会被接受。

选项
       -c, --config config-file
              使用 config-file。zabbix_sender 从 agentd 配置文件中读取服务器详细信息。
              默认情况下,zabbix_sender 不会读取任何配置文件。仅支持参数 Hostname, Server‐
              Active,    SourceIP,    TLSConnect,    TLSCAFile,    TLSCRLFile,
              TLSServerCertIssuer,  TLSServerCertSubject, TLSCertFile, TLSKey‐
              File, TLSPSKIdentity 和 TLSPSKFile。通过 HostnameItem 参数定义的 Hostname
              不会被读取,在这种情况下应通过命令行指定主机名(参见 -s 选项)。agent 的
              ServerActive 配置参数中定义的所有地址都会用于发送数据。如果某个地址发送批量
              数据失败,则后续批次不会再发送到该地址。

       -z, --zabbix-server server
              Zabbix 服务器 的主机名或 IP 地址。如果某个主机由 proxy 监控,则应改用
              proxy 的主机名或 IP 地址。与 --config 一起使用时,会覆盖 agentd 配置文件中
              ServerActive 参数指定的条目。

       -p, --port port
              指定运行在服务器上的 Zabbix server trapper 端口号。默认值为 10051。与
              --config 一起使用时,会覆盖 agentd 配置文件中 ServerActive 参数指定的端口
              条目。

       -I, --source-address IP-address
              指定源 IP 地址。与 --config 一起使用时,会覆盖 agentd 配置文件中指定的
              SourceIP 参数。

       -t, --timeout seconds
              指定超时时间。有效范围:1-300 秒(默认:60)

       -s, --host host
              指定该监控项所属的主机名(与 Zabbix 前端 中注册的名称一致)。主机 IP 地址和
              DNS 名称都不能使用。与 --config 一起使用时,会覆盖 agentd 配置文件中指定的
              Hostname 参数。

       -k, --key key
              指定要发送值到的监控项键值。

       -o, --value value
              指定监控项值。

       -i, --input-file input-file
              从输入文件加载值。指定 - 作为 <input-file> 可从标准输入读取值。文件中的每一
              行包含以空白字符分隔的内容:<hostname> <key> <value>。每个值都必须单独占一
              行。每行必须包含 3 个以空白字符分隔的条目:<hostname> <key> <value>,其中
              “hostname”是监控主机在 Zabbix 前端 中注册的名称,“key”是目标监控项键值,
              “value”是要发送的值。指定 - 作为 <hostname> 可使用 agent 配置文件中的主机
              名,或使用 --host 参数中的主机名。

              输入文件中的一行示例:

               "Linux DB3" db.connections 43

              值类型必须在 Zabbix 前端 的监控项配置中正确设置。zabbix_sender 在一次连接中
              最多会发送 250 个值。输入文件内容必须采用 UTF-8 编码。输入文件中的所有值将
              按从上到下的顺序依次发送。条目必须按照以下规则格式化:

                     • 支持带引号和不带引号的条目。

                     • 双引号是引用字符。

                     • 含有空白字符的条目必须加引号。

                     • 带引号条目中的双引号和反斜杠字符必须使用反斜杠转义。

                     • 不支持在不带引号的条目中使用转义。

                     • 在带引号字符串中支持换行转义序列 (\n)。

                     • 条目末尾的换行转义序列会被去除。

       -T, --with-timestamps
              此选项只能与 --input-file 选项一起使用。

              输入文件中的每一行必须包含 4 个以空白字符分隔的条目:
              <hostname> <key> <timestamp> <value>。时间戳应采用 Unix 时间戳格式。如果
              目标监控项有关联的触发器引用它,则所有时间戳必须按递增顺序排列,否则事件计算
              将不正确。

              输入文件中的一行示例:

               "Linux DB3" db.connections 1429533600 43

              更多详细信息请参见 --input-file 选项。

              如果向处于“no data”维护类型的主机发送带时间戳的值,则该值会被丢弃;但是,
              可以发送属于已过期维护时段的带时间戳值,并且该值会被接受。

       -N, --with-ns
              此选项只能与 --with-timestamps 选项一起使用。

              输入文件中的每一行必须包含 5 个以空白字符分隔的条目:
              <hostname> <key> <timestamp> <ns> <value>。

              输入文件中的一行示例:

               "Linux DB3" db.connections 1429533600 7402561 43

              更多详细信息请参见 --input-file 选项。

       -r, --real-time
              在接收到值后立即逐个发送。读取标准输入时可使用此选项。

       --tls-connect value
              如何连接到服务器或 proxy。可选值:

                   unencrypted
                               不加密连接(默认)

                   psk         使用 TLS 和预共享密钥进行连接

                   cert        使用 TLS 和证书进行连接

       --tls-ca-file CA-file
              包含用于对端证书验证的顶级 CA 证书的文件完整路径名。

       --tls-crl-file CRL-file
              包含已吊销证书的文件完整路径名。

       --tls-server-cert-issuer cert-issuer
              允许的服务器证书颁发者。

       --tls-server-cert-subject cert-subject
              允许的服务器证书主题。

       --tls-cert-file cert-file
              包含证书或证书链的文件完整路径名。

       --tls-key-file key-file
              包含私钥的文件完整路径名。

       --tls-psk-identity PSK-identity
              PSK 标识字符串。

       --tls-psk-file PSK-file
              包含预共享密钥的文件完整路径名。

       --tls-cipher13 cipher-string
              OpenSSL 1.1.1 或更高版本中用于 TLS 1.3 的密码字符串。覆盖默认的密码套件选择
              条件。如果 OpenSSL 版本低于 1.1.1,则此选项不可用。

       --tls-cipher cipher-string
              GnuTLS 优先级字符串(用于 TLS 1.2 及以上)或 OpenSSL 密码字符串(仅用于
              TLS 1.2)。覆盖默认的密码套件选择条件。

       -v, --verbose
              详细模式,-vv 可显示更多细节。

       -h, --help
              显示此帮助并退出。

       -V, --version
              输出版本信息并退出。

退出状态
       如果值已发送并且全部被服务器成功处理,则退出状态为 0。如果数据已发送,但至少有一个
       值处理失败,则退出状态为 2。如果数据发送失败,则退出状态为 1。

示例
       zabbix_sender -c  /etc/zabbix/zabbix_agentd.conf  -k  mysql.queries  -o
       342.45
              将 342.45 作为受监控主机的 mysql.queries 监控项值发送。使用 agent 配置文件
              中定义的受监控主机和 Zabbix 服务器。

       zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -s "Monitored Host"  -k
       mysql.queries -o 342.45
              使用 agent 配置文件中定义的 Zabbix 服务器,将 342.45 作为主机 Monitored
              Host 的 mysql.queries 监控项值发送。

       zabbix_sender -z 192.168.1.113 -i data_values.txt
              将文件 data_values.txt 中的值发送到 IP 为 192.168.1.113 的 Zabbix 服务器。
              主机名和键值在文件中定义。

       echo "- hw.serial.number  1287872261  SQ4321ASDF"  |  zabbix_sender  -c
       /usr/local/etc/zabbix_agentd.conf -T -i -
              从命令行向 agent 配置文件中指定的 Zabbix 服务器发送一个带时间戳的值。输入数
              据中的短横线表示主机名也应使用同一配置文件中的值。

       echo '"Zabbix server" trapper.item ""' | zabbix_sender -z 192.168.1.113
       -p 10000 -i -
              从命令行向 IP 地址为 192.168.1.113、端口为 10000 的 Zabbix 服务器发送某个
              监控项的空值。空值必须用空双引号表示。

       zabbix_sender -z 192.168.1.113  -s "Monitored Host" -k mysql.queries -o
       342.45  --tls-connect  cert  --tls-ca-file  /home/zabbix/zabbix_ca_file
       --tls-cert-file      /home/zabbix/zabbix_agentd.crt      --tls-key-file
       /home/zabbix/zabbix_agentd.key
              使用 TLS 证书,将 342.45 作为主机 Monitored Host 的 mysql.queries 监控项
              值发送到 IP 为 192.168.1.113 的服务器。

       zabbix_sender -z 192.168.1.113  -s "Monitored Host" -k mysql.queries -o
       342.45  --tls-connect  psk  --tls-psk-identity  "PSK  ID Zabbix agentd"
       --tls-psk-file /home/zabbix/zabbix_agentd.psk
              使用 TLS 和预共享密钥(PSK),将 342.45 作为主机 Monitored Host 的
              mysql.queries 监控项值发送到 IP 为 192.168.1.113 的服务器。

另请参见
       文档

       zabbix_agentd(8),  zabbix_get(1),  zabbix_proxy(8),   zabbix_server(8),
       zabbix_js(1), zabbix_agent2(8), zabbix_web_service(8)

Zabbix                            2022-01-06                  ZABBIX_SENDER(1)