Obtaining the API version

One of the simplest ways to obtain the API version in Zabbix is probably by Zabbix itself making use of the HTTP agent item and some JSON preprocessing. For this, we'll create a new item. It doesn't really matter on what host—let's do it on A test host. Go to Configuration | Hosts and create a new item on our A test host host with the following parameters:

  • Name: Check Zabbix API Version
  • Type: HTTP agent
  • Keycheck_zabbix_api_version
  • URL: http://<zabbix-server-ip>/zabbix/api_jsonrpc.php
  • Request type: POST
  • Request body type: JSON data
  • Request body: This field is filled with the following value:
 {
"jsonrpc": "2.0",
"method": "apiinfo.version",
"params": [],
"id": 1
}
  • Retrieve mode: Body
  • Type of information: Character

Next, we have to add some information in the Preprocessing tab as the result would be a JSON string looking like this: {"jsonrpc":"2.0","result":"4.0.2","id":1}. This should look like what's shown in the following screenshot:

 So, in the Preprocessing tab, select JSON Path and, for the Parameters field, write $.result:

The end result should look similar and in the latest data, we can then read out the version from our API:

In the Request body field, we added some JSON information; the reason we knew what to add here was because this is well explained in the online Zabbix documentation—I added the URL as a reference at the end of this chapter.

It's also good to know that, starting from Zabbix 2.0.4, the API version matches the Zabbix version.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset