zabbix api / python module

zabbix api / python module

  • Written by
    Walter Doekes
  • Published on

Today, my choice of Python modules to Interface with Zabbix. They are all pretty similar, so that made it harder to choose.

Here the six modules, as mentioned on the Zabbix wiki are, in the order of my preference. Note that second and third came close, but I favor clean documented code and fewer dependencies. The last ones didn’t get tested because of my Python3 requirement.

zabbix-client

# pip: zabbix-client
# pep: 99%
# last-update: Aug. 2014
# pros: header-docs
# cons: interface-for-login-is-different
from zabbix_client import ZabbixServerProxy
zapi = ZabbixServerProxy(url)
zapi.user.login(user=user, password=password)
rows = zapi.host.get(templateids=['10500'], output=['name', 'hostgroup'],
                     selectGroups=['name'])

pyzabbix

# pip: pyzabbix
# pep: 90%
# last-update: Oct. 2014
# pros: small, travis-build-check
# cons: depends-on-requests
from pyzabbix import ZabbixAPI
zapi = ZabbixAPI(url)
zapi.login(user=user, password=password)
rows = zapi.host.get(templateids=['10500'], output=['name', 'hostgroup'],
                     selectGroups=['name'])

zabbix-api-gescheit

# pip: zabbix-api
# pep: 75%
# last-update: Feb. 2015
# cons: interface-takes-dicts-instead-of-kwargs, bad-github-name
from zabbix_api import ZabbixAPI
zapi = ZabbixAPI(url)
zapi.login(user=user, password=password)
rows = zapi.host.get({'templateids': ['10500'], 'output': ['name', 'hostgroup'],
                      'selectGroups': ['name']})

zabbix-api-gnetsman

# pip: zabbix-api-gnetsman (except it wasn't found when I tried it)
# pros: unneeded-functionality
# cons: unneeded-functionality, depends-on-zabbix-api

py-zabbix

# pip: zabbix (previously: py-zabbix)
# pros: zabbix-sender-support
# cons: bad-indentation, no-py3

ZabbixPythonApi

# pip: ?
# cons: no-py3

Back to overview Newer post: proxmox api / python module Older post: asterisk / dialplan / variable expansion / security