21 lines
643 B
Python
21 lines
643 B
Python
#!/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)
|