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
introduction I used postgresql database for some ...
Today I will introduce how to enable the Linux su...
Preface Yesterday, there was a project that requi...
Problem Description Install nginx on Tencent Clou...
IIS7 needs to confirm whether the "URL REWRI...
1. Prerequisites Since I have installed it severa...
1. View the types of fields in the table describe...
Table of contents What is a skeleton screen How t...
Table of contents Preface Array.prototype.include...
as follows: -m, --memory Memory limit, the format...
This article shares the specific code of swiper+e...
Written in front In today's Internet field, N...
Table property settings that work well: Copy code ...
echarts component official website address: https...
1. Data Deduplication In daily work, there may be...