In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to get the IP and hostname of all hosts on zabbix. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
zabbix
zabbix ([`zæbiks]) is an enterprise-class open source solution for distributed system monitoring and network monitoring based on a web-based interface.
zabbix monitors various network parameters to ensure the safe operation of server systems; and provides flexible notification mechanisms to allow system administrators to quickly locate/resolve existing problems.
zabbix consists of two parts, zabbix server and optional 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 introduces you to get the IP and hostname of all hosts on zabbix. The code is as follows:
#coding: utf-8#Get IP and hostname of all hosts on zabbix import requestsimport jsonimport csvimport timedef 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(hostep + ' ' + hosted + '\n') fdata.close() Thank you for reading! About "how to get the IP and host name of all hosts on zabbix" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!
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: 292
*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.