Using the Zabbix Get Command

Video Lecture

Using the 'Zabbix Get' Command Using the 'Zabbix Get' Command Using the Zabbix Get Command

Description

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

To install on ubuntu,

1
sudo apt install zabbix-get

For help use

1
zabbix_get -h

Try

1
zabbix_get -s <host-name-or-IP> -p 10050 -k agent.ping
1
zabbix_get -s <host-name-or-IP> -p 10050 -k agent.version
1
zabbix_get -s <host-name-or-IP> -p 10050 -k agent.hostname
1
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 command also needs to be listed in the Server parameter in the configuration file for the host being queried.

Also,

If you are using psk encryption you will need to also enter the psk information, or add unencrypted to the options for TLSAccept in the agents configuration file on the host being queried.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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. Zabbix_get executes like a passive check, so the server running the command also needs to be listed in the Server parameter in the configuration file for the host being queried.

If your agent accepts psk encryption, the 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.

It is not necessary to set enableRemoteCommands=1 or modify the DenyKey or AllowKey parameters.

Zabbix Get