zabbix_sender

章节:用户命令 (1)
更新日期:2021-06-01
索引 Return to Main Contents


 

名称

zabbix_sender - Zabbix发送器实用工具

概要

zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s 主机 -k key -o value
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] [-s 主机] [-T] [-N] [-r] -i input-file
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address] [-t timeout] [-s 主机] -k key -o value
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address] [-t timeout] [-s 主机] [-T] [-N] [-r] -i input-file
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s 主机 --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 主机] --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 主机] --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 主机] --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 主机 --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 主机] --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 主机] --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] -c config-file [-z server] [-p port] [-I IP-address] [-t timeout] [-s 主机] --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 -h
zabbix_sender -V  

描述

zabbix_sender 是一个用于向 Zabbix server 或 proxy 发送监控数据的命令行工具。在 Zabbix server 上需要创建一个类型为 Zabbix trapper 的 监控项 并配置对应键值。注意传入的值仅会接受该 监控项 的 Allowed 主机 字段中指定的 主机。

选项

-c, --config config-file
使用 config-fileZabbix sender 从 agentd 配置file中读取服务器详细信息。默认情况下 Zabbix sender 不会读取任何配置file。仅支持参数 HostnameServerActiveSourceIPTLSConnectTLSCAFileTLSCRLFileTLSServerCertIssuerTLSServerCertSubjectTLSCertFileTLSKeyFileTLSPSKIdentityTLSPSKFile
通过 HostnameItem 参数定义的 Hostname 不会被获取,在这种情况下,主机名应通过命令行指定(参见 -s 选项)。
所有在agent ServerActive 配置参数中定义的地址都用于发送数据。如果批量数据发送到一个地址失败,后续批次将不会发送到该地址。

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

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

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

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

-s, --host 主机
指定 主机名 所属的 监控项(在 Zabbix 前端注册)。主机IP地址 和 DNS 名称无效。与 --config 一起使用时,覆盖 agentd 配置file中指定的 Hostname 参数。

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

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

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

输入file的一行示例:

"Linux DB3" db.connections 43

值类型必须在 Zabbix 前端的 监控项 配置中正确设置。Zabbix sender 将在一次连接中发送最多 250 个值。Size limit 用于从输入file发送值取决于 Zabbix 通信协议中描述的大小。输入file的内容必须采用 UTF-8 编码。所有来自输入file的值按 Top-down 顺序发送。条目必须按照以下规则格式化:

  • 支持带引号和不带引号的条目。
  • 双引号是引用字符。
  • 包含空格的条目必须加引号。
  • 带引号的条目中的双引号和反斜杠字符必须用反斜杠转义。
  • 不带引号的条目不支持转义。
  • 带引号的字符串支持换行转义序列(\n)。
  • 换行转义序列从条目末尾被修剪。

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

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

输入file的一行示例:

"Linux DB3" db.connections 1429533600 43

更多详情请参见选项 --input-file

如果为处于“无数据”维护类型的 一个主机 发送带时间戳的值,则该值将被丢弃;但是,可以为过期的维护期发送带时间戳的值,并且会被接受。

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

输入file的每一行必须包含 5 个以空格分隔的条目:<hostname> <key> <timestamp> <ns> <value>

输入file的一行示例:

"Linux DB3" db.connections 1429533600 7402561 43

更多详情请参见选项 --input-file

-r, --real-time
在接收到值时立即逐个发送。这可以在从标准输入读取时使用。

--tls-connect value
如何连接到 server 或 proxy。值:

 

未加密 不加密连接(默认)

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

证书 使用TLS和证书进行连接

--tls-ca-file CA-file 包含Top级别CA证书的file完整路径名 对等证书验证

--tls-crl-file CRL-file 包含已撤销证书的file的完整路径名

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

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

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

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

--tls-psk-identity PSK身份标识 PSK标识 string.

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

--tls-cipher13 cipher-string OpenSSL 1.1.1或更高版本中TLS 1.3的密码套件string. 覆盖 默认密码套件选择标准。如果 OpenSSL version 版本低于 1.1.1。

--tls-cipher cipher-string GnuTLS优先级string(适用于TLS 1.2及以上版本)或OpenSSL密码套件string (仅适用于TLS 1.2). 覆盖默认的密码套件选择标准.

-v, --verbose 详细模式,-vv 获取更多详情。

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

-V, --version 输出version信息并退出

 

退出状态

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

 

示例

zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k mysql.queries -o 342.45

342.45作为mysql.queries 监控项的值发送到被监控主机。使用在agent配置file中定义的被监控主机和Zabbix server。

zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -s "Monitored 主机" -k mysql.queries -o 342.45

342.45作为mysql.queries 监控项的值发送到Monitored 主机 主机,使用在agent配置file中定义的Zabbix server。


zabbix_sender -z 192.168.1.113 -i data_values.txt


将file data_values.txt中的值发送到IP为192.168.1.113的Zabbix server。主机名称和键在file中定义。


echo "- hw.serial.number 1287872261 SQ4321ASDF" | zabbix_sender -c /usr/local/etc/zabbix_agentd.conf -T -i -

从命令行发送带时间戳的值到Zabbix server,该服务器在agent配置file中指定。输入数据中的破折号表示主机名也应从同一配置file中使用。


echo '"Zabbix server" trapper.监控项 ""' | zabbix_sender -z 192.168.1.113 -p 10000 -i -

从命令行发送监控项的空值到IP地址为192.168.1.113、端口为10000的Zabbix server。空值必须用空双引号表示。

zabbix_sender -z 192.168.1.113 -s "Monitored 主机" -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

342.45作为mysql.queries 监控项的值发送到IP为192.168.1.113的服务器上的Monitored 主机 主机,使用带证书的TLS。

zabbix_sender -z 192.168.1.113 -s "Monitored 主机" -k mysql.queries -o 342.45 --tls-connect psk --tls-psk-identity "PSK ID Zabbix agentd" --tls-psk-file /home/zabbix/zabbix_agentd.psk

342.45作为mysql.queries 监控项的值发送到IP为192.168.1.113的服务器上的Monitored 主机 主机,使用预共享密钥(PSK)的TLS。

 

另请参阅

文档 https://www.zabbix.com/manuals

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

索引

名称

概述

描述

选项

退出状态

示例

参见

作者


本文档创建于: 2021年6月11日 GMT时间 08:42:39