Created
November 8, 2020 23:28
-
-
Save htnosm/ecd39bf2c9710e6d2ede5aa66e1ed4d3 to your computer and use it in GitHub Desktop.
Zabbix Export Sample. (Zabbix Ver 4.x)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyzabbix import ZabbixAPI | |
import os | |
import json | |
zapi = ZabbixAPI("Your Zabbix URL") | |
zapi.session.verify = False | |
zapi.login("Your Zabbix User", "Your Zabbix Password") | |
print("Connected to Zabbix API Version %s" % zapi.api_version()) | |
output_dir = './var' | |
os.makedirs(output_dir, exist_ok=True) | |
# hostgroup | |
hostgroups = zapi.hostgroup.get(selectHosts="extend") | |
with open(f"{output_dir}/hostgroups.json", 'w') as f: | |
json.dump(hostgroups, f, ensure_ascii=False, indent=2) | |
# host | |
hosts = zapi.host.get(selectItems="extend") | |
with open(f"{output_dir}/hosts.json", 'w') as f: | |
json.dump(hosts, f, ensure_ascii=False, indent=2) | |
# item | |
items = zapi.item.get(selectTriggers="extend", webitems=1) | |
with open(f"{output_dir}/items.json", 'w') as f: | |
json.dump(items, f, ensure_ascii=False, indent=2) | |
# triggers | |
triggers = zapi.trigger.get(selectItems="extend", expandExpression=True) | |
with open(f"{output_dir}/triggers.json", 'w') as f: | |
json.dump(triggers, f, ensure_ascii=False, indent=2) | |
# web_senarios (httptest) | |
web_senarios = zapi.httptest.get(selectHosts="extend", selectSteps="extend") | |
with open(f"{output_dir}/web_senarios.json", 'w') as f: | |
json.dump(web_senarios, f, ensure_ascii=False, indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment