搜索

为你解放双手,Python自动获取指定主机Zabbix监控图

发表于 2025-11-04 08:33:15 来源:益强智未来
为你解放双手,Python自动获取指定主机Zabbix监控图
复制#获取authkey  ZABBIX_URL = https://www.zabbix.cn ZABBIX_USERNAME = "user" ZABBIX_PASSWORD = "password" url = "{}/api_jsonrpc.php".format(ZABBIX_URL)  header = {"Content-Type": "application/json"}  # auth userandpassword data = {     "jsonrpc": "2.0",为解     "method": "user.login",     "params": {         "user": ZABBIX_USERNAME,         "password": ZABBIX_PASSWORD    },     "id": 1,  }  # 由于API接收的是json字符串,企商汇故需要转化一下  value = json.dumps(data).encode(utf-8)  # 对请求进行包装  req = request.Request(url,放双 headers=header, data=value)  # 验证并获取Auth ID  try:     # 打开包装过的url     result = request.urlopen(req)  except Exception as e:     print("Auth Failed, Please Check Your Name And Password:", e)  else:     response = result.read()     # 上面获取的云服务器是bytes类型数据,WordPress模板动获定主故需要decode转化成字符串     page = response.decode(utf-8)     # 将此json字符串转化为python字典     page = json.loads(page)     result.close()     print("Auth Successful. The Auth ID Is: {}".format(page.get(result)))  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.
随机为您推荐
版权声明:本站资源均来自互联网,如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

Copyright © 2016 Powered by 为你解放双手,Python自动获取指定主机Zabbix监控图,益强智未来  滇ICP备2023006006号-17sitemap

回顶部