Drumroll please…
Introducing… zoooooooop!
I got sick of hard-coding calls to the python Zabbix API module (https://github.com/gescheit/scripts), so I wrote zoop: Zabbix Object-Oriented Python.
With zoop, I have made (and will continue to add) classes, or objects if you will, of Zabbix API calls. Need to create a new item?
from zoop import * api = zoop(url='http://www.example.com/zabbix', username='zabbixusername', password='zabbixpassword') host = api.host() host.get(name='zabbix.example.com')
The .get() method will fill the object with the API information, if the host exists (will search by either host, name or hostid)
Once filled, the host object behaves like a python dict type, so you can call the values or set them like this: host[“hostid”]
item = api.item() item["hostid"] = host["hostid"] item["key_"] = 'myitemkey' item["other item values"] = etc.
There is a .get() method for items as well, e.g. item.get(key_=’my_item_key’, hostid=host[“hostid”]), which will fill the item object with values from the API.
Please feel free to browse the source. There is a LOT that could be done here to extend this and make it better, and encompass more API calls. This is just for starters!
zoop is available at https://github.com/untergeek/zoop