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
1. Environmental preparation: Operating system: C...
1. When the mobile terminal processes the list sl...
1. Avoid declaring the page as XML type . The pag...
Library Management Create a library create databa...
NextCloud You can share any files or folders on y...
1 Check the Linux distribution version [root@type...
Solution to the problem that there is no unzip co...
Table of contents Overview Create a type definiti...
Frameset pages are somewhat different from ordina...
In the previous article, we used Docker to build ...
I followed the tutorial on W3school. I think the t...
sudo configuration file The default configuration...
Due to encoding reasons, garbled characters will ...
Google's goal with Flutter has always been to...
Table of contents background Provide / Inject Ext...