In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail about the use of Zabbix Api in the Linux shell environment. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
You can call it directly in the linux shell environment, according to the official website: you need to log in and obtain an authentication token before accessing any data in Zabbix. 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.phpHTTP/1.1 200 OKDate: Fri 26 Oct 2018 07:46:05 GMTServer: Apache/2.4.6 (CentOS) PHP/5.6.36X-Powered-By: PHP/5.6.36Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-TypeAccess-Control-Allow-Methods: POSTAccess-Control-Max-Age: 1000Content-Length: 68Content-Type: application/json {"jsonrpc": "2.0", "result": "77bfe44db3f5c016477110c5748ac3e1", "id": 0}
According to the official website, the user authentication token "77bfe44db3f5c016477110c5748ac3e1" is returned, which is required for all subsequent api requests.
According to the gourd painting ladle, another query, this time with the above authentication token:
[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.phpHTTP/1.1 200 OKDate: Fri 26 Oct 2018 08:17:23 GMTServer: Apache/2.4.6 (CentOS) PHP/5.6.36X-Powered-By: PHP/5.6.36Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-TypeAccess-Control-Allow-Methods: POSTAccess-Control-Max-Age: 1000Content-Length: 111Content-Type: application/json {"jsonrpc": "2.0", "result": [{"hostid": "10084", "host": "Zabbix server" "interfaces": [{"ip": "127.0.0.1"}]}], "id": 4}
Hostname Zabbix server, host Ip 127.0.0.1 is returned
In fact, how to use API should be based on the official website documents, such as apiinfo.version, which clearly states that this method can be used for unauthenticated users and must be called without the "auth" parameter in sending JSON-RPC requests.
Examples are as follows:
[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.phpHTTP/1.1 200 OKDate: Fri 26 Oct 2018 08:40:17 GMTServer: Apache/2.4.6 (CentOS) PHP/5.6.36X-Powered-By: PHP/5.6.36Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-TypeAccess-Control-Allow-Methods: POSTAccess-Control-Max-Age: 1000Content-Length: 42Content-Type: application/json {"jsonrpc": "2.0", "result": "3.4.14", "id": 5}
Shows that the Zabbix API version of the target host is 3.4.14
This is the end of this article on "what is the use of Zabbix Api in the Linux shell environment". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.