zabbix Zabbix ([`zæbiks]) is an enterprise-level open source solution that provides distributed system monitoring and network monitoring capabilities based on a WEB interface. Zabbix can monitor various network parameters to ensure the safe operation of the server system; and provide a flexible notification mechanism to allow system administrators to quickly locate/solve various existing problems. Zabbix consists of two parts, Zabbix server and the optional component Zabbix agent. Zabbix server can provide remote server/network status monitoring, data collection and other functions through SNMP, Zabbix agent, ping, port monitoring and other methods. It can run on Linux, Solaris, HP-UX, AIX, Free BSD, Open BSD, OS X and other platforms. The following code shows you how to get the IP and host names of all hosts on zabbix. The code is as follows: #coding:utf-8 #Get the IP and host name of all hosts on zabbix import requests import json import csv import time def get_token(): data = { "jsonrpc": "2.0", "method": "user.login", "params": { "user": username, "password": password }, "id": 0 } r = requests.get(zaurl, headers=header, data=json.dumps(data)) auth = json.loads(r.text) return auth["result"] def getHosts(token): data = { "jsonrpc": "2.0", "method": "host.get", "params": { "output": [ "hostid", "host" ], "selectInterfaces": [ "interfaceid", "ip" ] }, "id": 2, "auth": token, } request = requests.post(zaurl, headers=header, data=json.dumps(data)) dict = json.loads(request.content) # print (dict['result']) return dict['result'] if __name__ == "__main__": zaurl="http://xx.xx.xx.xx/zabbix/api_jsonrpc.php" header = {"Content-Type": "application/json"} username = "xx" password = "xx" token = get_token() hostlist = getHosts(token) datafile = "zabbix.txt" fdata = open(datafile,'w') for i in hostlist: hostid = i['hostid'] hostip = i['host'] fdata.write(hostip + ' ' + hostid + '\n') fdata.close() Summarize The above is the example code for getting the IP and host name of all hosts on zabbix introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Detailed explanation of cross-usage of Ref in React
>>: How to enable the slow query log function in MySQL
text OK, next it’s time to show the renderings. O...
1.17.9 More delicious, really Nginx download addr...
Rendering After looking up relevant information o...
As shown in the figure: There are many files conne...
summary Project description format <img src=&q...
When learning mybatis, I encountered an error, th...
This article shares the specific code for WeChat ...
During the development process, we often use the ...
Recently, I'm learning to use React with Thre...
Table of contents Manual deployment 1. Create a s...
1. Optimization of commonly used HTML tags HTML s...
Imagine a scenario where, when designing a user t...
Table of contents Preface What does yarn create d...
Table of contents 1. Install vue-video-player 2. ...
When it comes to tool-type websites, we first hav...