Table of Contents

7 Get

概览

Zabbix get 是一个命令行工具,可用于与 Zabbix agent 通信并从 agent 检索所需信息。

该工具通常用于 Zabbix agents 的故障排除。

另请参阅 zabbix_utils - 一个具有内置功能的 Python 库,可以像 Zabbix get 一样工作。

运行Zabbix get

在UNIX下运行Zabbix get以获取agent的处理器负载值的示例:

cd bin
       ./zabbix_get -s 127.0.0.1 -p 10050 -k system.cpu.load[all,avg1]

运行Zabbix get以从网站捕获string的另一个示例:

cd bin
       ./zabbix_get -s 192.168.1.1 -p 10050 -k "web.page.regexp[www.example.com,,,\"USA: ([a-zA-Z0-9.-]+)\",,\1]"

请注意,这里的监控项键包含空格,因此使用引号标记监控项键供shell识别。引号不是监控项键的一部分;它们将被shell修剪,并且不会传递给Zabbix agent。

如果监控项键不受支持,Zabbix get将返回退出代码1

Zabbix get接受以下命令行参数:

```ini -s --host <host name or IP> Specify host name or IP address of a host -p --port <port number> Specify port number of agent running on the host (default: 10050) -I --source-address <IP address> Specify source IP address -t --timeout <seconds> Specify timeout. Valid range: 1-30 seconds (default: 30 seconds) -k --key <item key> Specify key of item to retrieve value for -P --protocol <value> Protocol used to communicate with agent. Values: auto - connect using JSON protocol, fallback and retry with plaintext protocol (default) json - connect using JSON protocol plaintext - connect using plaintext protocol where just item key is sent (6.4.x and older releases) -h --help Display this help message -V --version Display version number

--tls-connect <value> How to connect to agent. Values: unencrypted - connect without encryption (default) psk - connect using TLS and a pre-shared key cert - connect using TLS and a certificate --tls-ca-file <CA file> Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification --tls-crl-file <CRL file> Full pathname of a file containing revoked certificates --tls-agent-cert-issuer <cert issuer> Allowed agent certificate issuer --tls-agent-cert-subject <cert subject> Allowed agent certificate subject --tls-cert-file <cert file> Full pathname of a file containing the certificate or certificate chain --tls-key-file <key file> Full pathname of a file containing the private key --tls-psk-identity <PSK-identity> Unique, case sensitive string used to identify the pre-shared key --tls-psk-file <PSK-file> Full pathname of a file containing the pre-shared key --tls-cipher13 <cipher-string> Cipher string for OpenSSL 1.1.1 or newer for TLS 1.3. Override the default ciphersuite selection criteria. This option is not available if OpenSSL version is less than 1.1.1 --tls-cipher <cipher-string> GnuTLS priority string (for TLS 1.2 and up) or OpenSSL cipher string (only for TLS 1.2). Override the default ciphersuite selection criteria ```请参阅Zabbix get manpage以获取更多信息。

在Windows上可以类似地运行Zabbix get:

zabbix_get.exe [options]