Add zabbix_api_v1.py
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
from zabbix_utils import ZabbixAPI
|
||||||
|
from datetime import datetime
|
||||||
|
# Zabbix server details
|
||||||
|
zabbix_url = "https://student-XX-zbxtr-YYYY.zabbix.training"
|
||||||
|
api = ZabbixAPI(url=zabbix_url)
|
||||||
|
api.login(token="<PERMANENT-API-TOKEN>")
|
||||||
|
print("Connected to Zabbix API Version %s" % api.api_version())
|
||||||
|
hosts = api.host.get(
|
||||||
|
search={"name":"API Server"},
|
||||||
|
output=["hostid","name"]
|
||||||
|
)
|
||||||
|
print (hosts)
|
||||||
|
hostid = hosts[0]["hostid"]
|
||||||
|
print ('HostID: ' + str(hostid))
|
||||||
|
items = api.item.get (
|
||||||
|
hostids=hostid,
|
||||||
|
output=["itemid","name","key_","flags"]
|
||||||
|
)
|
||||||
|
print (items)
|
||||||
Reference in New Issue
Block a user