You can call it directly in the Linux shell environment. According to the official website: Before accessing any data in Zabbix, you need to log in and obtain an authentication token. This can be done using the user.login method. [root@localhost ~]# curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method":"user.login","params":{"user":"Admin","password":"zabbix"},"auth": null,"id":0}' http://192.168.149.129/zabbix/api_jsonrpc.php HTTP/1.1 200 OK Date: Fri, 26 Oct 2018 07:46:05 GMT Server: Apache/2.4.6 (CentOS) PHP/5.6.36 X-Powered-By: PHP/5.6.36 Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: POST Access-Control-Max-Age: 1000 Content-Length: 68 Content-Type: application/json {"jsonrpc":"2.0","result":"77bfe44db3f5c016477110c5748ac3e1","id":0} According to the official website, the user authentication token "77bfe44db3f5c016477110c5748ac3e1" is returned, and all subsequent API requests need to carry it. I queried another one in the same way, this time with the authentication token from above: [root@localhost ~]# curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method":"host.get","params":{"output":["host"],"selectInterfaces":["ip"]},"auth": "77bfe44db3f5c016477110c5748ac3e1","id":4}' http://192.168.149.129/zabbix/api_jsonrpc.p hp HTTP/1.1 200 OK Date: Fri, 26 Oct 2018 08:17:23 GMT Server: Apache/2.4.6 (CentOS) PHP/5.6.36 X-Powered-By: PHP/5.6.36 Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: POST Access-Control-Max-Age: 1000 Content-Length: 111 Content-Type: application/json {"jsonrpc":"2.0","result":[{"hostid":"10084","host":"Zabbix server","interfaces":[{"ip":"127.0.0.1"}]}],"id":4} The returned host name is Zabbix server, and the host IP is 127.0.0.1 In fact, how to use the API still depends on the official website documentation, such as apiinfo.version. The official website clearly states: This method can be used for unauthenticated users and must be called without adding the "auth" parameter in the JSON-RPC request. Here is an example: [root@localhost ~]# curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method":"apiinfo.version","params":[],"id":5}' http://192.168.149.129/zabbix/api_ jsonrpc.php HTTP/1.1 200 OK Date: Fri, 26 Oct 2018 08:40:17 GMT Server: Apache/2.4.6 (CentOS) PHP/5.6.36 X-Powered-By: PHP/5.6.36 Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: POST Access-Control-Max-Age: 1000 Content-Length: 42 Content-Type: application/json {"jsonrpc":"2.0","result":"3.4.14","id":5} The Zabbix API version of the target host is 3.4.14 Attached official website link: https://www.zabbix.com/documentation/3.4/en/manual/api Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Example of using Vue built-in component keep-alive
>>: React error boundary component processing
This article explains the difference between arro...
<br />"There are no ugly women in the w...
Here is a text scrolling effect implemented with ...
There is no data directory, my-default.ini and my...
The solution to forgetting the initial password o...
Table of contents Method 1: set: It is not a data...
This article example shares the specific code for...
Original text: http://www.planabc.net/2008/08/05/...
Grammatical rules SELECT column_name(s) FROM tabl...
Table of contents Overview Hash Properties Host p...
We can create jsx/tsx files directly The project ...
1. Type introduction 1.1 Domain-based virtual hos...
This article example shares the specific code of ...
Table of contents (1) Introduction: (2) The ways ...
When encapsulating Vue components, I will still u...