章节:用户命令 (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] [-g] -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] [-g] -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] [-g] -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] [-g] -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] [-g] -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] [-g] -i input-file
zabbix_sender -h
zabbix_sender -V
zabbix_sender 是一个用于向 Zabbix server 或 proxy 发送监控数据的命令行工具。在 Zabbix server 上需要创建一个类型为 Zabbix trapper 的 监控项 并配置对应键值。请注意,传入的值仅会接受该 监控项 的 Allowed 主机 字段中指定的 主机。
-c, --config config-file 使用 config-file。Zabbix sender 从该文件中读取服务器详细信息 agentd配置file。默认情况下Zabbix sender不会读取 任何配置file. 仅参数Hostname, ListenBacklog, ServerActive, SourceIP, TLSConnect, TLSCAFile, TLSCRLFile, TLSServerCertIssuer, TLSServerCertSubject, TLSCertFile, TLSKeyFile、TLSPSKIdentity 和 TLSPSKFile 均受支持。 通过HostnameItem参数定义的主机名将不会被识别,在这种情况下,主机名应通过命令行指定(参见-s选项)。 在 agent ServerActive 配置参数中定义的所有地址 用于发送数据。如果批量数据发送到某个目标失败 地址,以下批次不会发送到此地址。
-z, --zabbix-server server Zabbix server的主机名或IP地址。如果一个主机由 proxy, proxy 主机名 或 IP 地址应被替代使用。当使用时 与 --config 一起使用时,覆盖 ServerActive 的条目 在agentd配置中指定的参数file
-p, --port port 指定服务器上运行的Zabbix server trapper的端口号。 默认值为10051。当与 --config 一起使用时,将覆盖 ServerActive 参数在 agentd 中指定的端口条目 配置 file
-I, --source-address IP地址 指定源IP地址。当与--config一起使用时, 覆盖在agentd配置中指定的SourceIP参数file。
-t, --timeout 秒数 指定超时时间。有效范围:1-300秒(默认值:60)
-s, --host 主机 指定 主机名 所属的 监控项(在Zabbix中注册的 前端). 主机IP地址 和 DNS 名称将不起作用. 当使用时 与 --config 一起使用时,会覆盖指定的 Hostname 参数 在agentd配置中file
-k, --key key 指定发送值的监控项键
-o, --value value 指定 监控项 值。
-i, --input-file input-file 从输入file加载值。指定-为<input-file>以 从标准输入读取值。file的每一行包含空白字符 分隔格式: <主机名> <键> <值>. 每个值 必须单独占一行。每行必须包含3个空格 分隔条目格式:<主机名> <键> <值>,其中 "hostname" 是被监控主机在Zabbix中注册的名称 前端,"key"是目标监控项键,"value"是要发送的值。 指定 - 作为 <hostname> 以使用来自 agent 的主机名 配置 file 或来自 --host 参数
输入行示例 file:
"Linux DB3" 数据库连接数 43
在Zabbix前端监控项配置中必须正确设置值类型 Zabbix sender将在一次连接中发送最多250个值. Size limit 用于从输入file发送数值 取决于Zabbix通信协议中描述的尺寸 输入file的内容必须采用UTF-8编码格式 输入file的所有值按顺序Top向下发送 条目必须按照以下规则进行格式化:
-T, --with-timestamps 此选项只能与--input-file选项一起使用。
输入file的每一行必须包含4个以空格分隔的条目: <主机名> <键值> <时间戳> <数值>. 时间戳应以Unix时间戳格式指定。如果目标 监控项 存在触发器引用它时,所有时间戳必须按递增顺序排列 顺序,否则事件计算将不正确。
输入行示例 file:
"Linux DB3" 数据库连接数 1429533600 43
更多详情请参见选项 --input-file.
如果为一个主机发送的时间戳值处于“无数据”状态 维护类型时此值将被丢弃;然而,它 可以为已过期的维护期发送带时间戳的值 周期,它将被接受。
-N, --with-ns 此选项只能与--with-timestamps选项一起使用。
输入file的每一行必须包含5个以空格分隔的条目: <主机名> <键值> <时间戳> <纳秒> <value>**.
输入行示例 file:
"Linux DB3" db.connections 1429533600 7402561 43
有关更多详情,请参阅选项 --input-file。
-r, --real-time 逐个发送接收到的值。这可用于 从标准输入读取时。
-g, --group 按主机分组数值并单独批量发送至每个主机
--tls-connect 值 如何连接到server 或 proxy. 值:
未加密
不使用加密连接(默认)
psk
使用TLS和预共享密钥连接
cert
使用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 cert-subject
允许的服务器证书主题
--tls-cert-file cert-file
包含证书或证书链的file完整路径名
--tls-key-file key-file
包含私钥的file完整路径名
--tls-psk-identity PSK-identity
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
使用证书通过TLS将342.45作为mysql.queries 监控项的值发送到IP为192.168.1.113的服务器上的Monitored 主机 主机.
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
使用预共享密钥(PSK)通过TLS将342.45作为mysql.queries 监控项的值发送到IP为192.168.1.113的服务器上的Monitored 主机 主机.
文档 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