Zabbix Api

glitchlist Blog Leave a Comment

One of the powerful functionality of Zabbix Monitoring System is the use of Rest API for interacting with the frontend

You can create/delete/update an host and modifying a lot of parameters using , for example, a python script for automating some task and procedure.

First of all you have to verify that a API is full operational on your frontend. For simplicity we will use a curl for sending a POST request:

curl  -H "Content-Type: application/json-rpc" -X POST  http://zabbix/zabbix/api_jsonrpc.php -d '{"jsonrpc":"2.0","method":"apiinfo.version","id":1,"auth":null,"params":{}}'

the result should be this :


Go ahead!

Now we have to retrieve a token :

curl  -H "Content-Type: application/json-rpc" -X POST   https://zabbix/zabbix//api_jsonrpc.php -d '{"jsonrpc":"2.0","method":"user.login","id":1,"auth":null,"params":{"user":"Admin","password":"zabbix"}}'

and the result :


Now with the token is possible to send what you want

In this example we retrieve a list of host :

curl  -H "Content-Type: application/json-rpc" -X POST   http://zabbixn/zabbix/api_jsonrpc.php -d '{"jsonrpc":"2.0","method":"host.get","id":1,"auth":"9be759b144adeea966225a7e901","params":{"output":["host"]}}'

the result is ever in a json format.

Here the official documentation of Rest API, you have to choose the correct version of your installation

Leave a Reply

Your email address will not be published. Required fields are marked *