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 的监控项,并使用相应的 key。 请注意,只有来自该监控项 Allowed hosts 字段中指定的主机的传入值才会被接受。
选项
-c, --config config-file
使用 config-file。Zabbix sender 从 agentd 配置文件中读取服务器详细信息。默认情况下,Zabbix sender 不读取任何配置文件。仅支持以下参数:Hostname、ServerActive、SourceIP、TLSConnect、TLSCAFile、TLSCRLFile、TLSServerCertIssuer、TLSServerCertSubject、TLSCertFile、TLSKeyFile、TLSPSKIdentity 和 TLSPSKFile。通过 HostnameItem 参数定义的 Hostname 不会被获取,在这种情况下,应通过命令行指定主机名(参见 -s 选项)。agent ServerActive 配置参数中定义的所有地址都会用于发送数据。如果向某个地址发送批量数据失败,则后续批次不会发送到该地址。
-z, --zabbix-server server
Zabbix 服务器的主机名或 IP 地址。如果主机由 proxy 监控,则应改用 proxy 的主机名或 IP 地址。与 --config 一起使用时,会覆盖 agentd 配置文件中指定的 ServerActive 参数条目。
-p, --port port
指定服务器上运行的 Zabbix 服务器 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
指定要向其发送值的监控项 key。
-o, --value value
指定监控项值。
-i, --input-file input-file
从输入文件加载值。将 - 作为 <input-file> 可从标准输入读取值。文件中的每一行包含以空白分隔的:<hostname> <key> <value>。每个值必须单独占一行。每一行必须包含 3 个以空白分隔的条目:<hostname> <key> <value>,其中 "hostname" 是在 Zabbix 前端中注册的被监控主机名称,"key" 是目标监控项 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 选项。
如果为处于“无数据”维护类型中的主机发送带时间戳的值,则该值将被丢弃;但是,可以在维护期已过期后发送带时间戳的值,并且会被接受。
-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
用于 TLS 1.3 的 OpenSSL 1.1.1 或更新版本的 cipher 字符串。覆盖默认的密码套件选择标准。如果 OpenSSL 版本低于 1.1.1,则此选项不可用。
--tls-cipher cipher-string
GnuTLS 优先级字符串(用于 TLS 1.2 及以上)或 OpenSSL cipher 字符串(仅用于 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 服务器。主机名和 key 在文件中定义。
echo "- hw.serial.number 1287872261 SQ4321ASDF" | zabbix_sender -c
/usr/local/etc/zabbix_agentd.conf -T -i -
从命令行向 Zabbix 服务器发送一个带时间戳的值,服务器由 agent 配置文件指定。输入数据中的短横线表示主机名也应使用同一配置文件中的设置。
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)