Skip to content

Using the Zabbix Get Command

Video Lecture

Using the Zabbix Get Command

Description

zabbix_get is a command line utility for getting data from Zabbix agents.

You don't need to have Zabbix server, proxy or an agent running on the same OS to use the zabbix_get utility, but you do need to make sure you have the correct version for your operating system.

Download the appropriate Zabbix version and repository for your operating system. I am using Zabbix 6 LTS on Ubuntu 20.04.

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
apt update

Now to install the zabbix_get program.

sudo apt install zabbix-get

For help use

zabbix_get -h

zabbix_get is used to query for data from a remote Zabbix agent.

Try

zabbix_get -s <host-name-or-IP> -p 10050 -k agent.ping
zabbix_get -s <host-name-or-IP> -p 10050 -k agent.version
zabbix_get -s <host-name-or-IP> -p 10050 -k agent.hostname
zabbix_get -s <host-name-or-IP> -p 10050 -k system.cpu.load[all,avg1]

Note

zabbix_get executes like a passive check, so the hostname of the server running the zabbix_get command also needs to be listed in the Server parameter in the configuration file for the host being queried.

Also,

If the agent your are querying expects PSK encryption, then you will need to also enter that PSK information, or add unencrypted to the options for TLSAccept in the agents configuration file on the host being queried.

Usage

zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address] -k item-key
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address]
                --tls-connect cert --tls-ca-file CA-file
                [--tls-crl-file CRL-file] [--tls-agent-cert-issuer cert-issuer]
                [--tls-agent-cert-subject cert-subject]
                --tls-cert-file cert-file --tls-key-file key-file
                [--tls-cipher13 cipher-string] [--tls-cipher cipher-string]
                -k item-key
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address]
                --tls-connect psk --tls-psk-identity PSK-identity
                --tls-psk-file PSK-file [--tls-cipher13 cipher-string]
                [--tls-cipher cipher-string] -k item-key
zabbix_get -h
zabbix_get -V

Example Python Script

1
2
import subprocess
subprocess.call(["zabbix_get", "-s", "<host-name-or-IP>", "-p", "10050", "-k", "agent.version"])

Troubleshooting

If you get the error, "Check access restrictions in Zabbix agent configuration", then you need to add the requesting hosts IP address to the Server parameter in the configuration file for the host being queried since zabbix_get executes like a passive check to the host.

If your agent accepts PSK encryption, then ensure you also send the PSK parameters in your zabbix_get command. Or add the option unencrypted to the TLSAccept parameter in the configuration file for the host being queried.

Zabbix Get

Comments