py-zabbix
raw JSON → 1.1.7 verified Mon Apr 27 auth: no python
Python module to work with Zabbix API and send trapper data. Version 1.1.7. Low release cadence, maintained sporadically.
pip install py-zabbix Common errors
error ModuleNotFoundError: No module named 'pyzabbix' ↓
cause Installed py-zabbix but imported with wrong name or not installed.
fix
Run 'pip install py-zabbix' and import as 'from pyzabbix import ...'.
error zabbix.api.ZabbixAPIException: Invalid JSON. Check Zabbix server version. ↓
cause Using JSON-RPC call with incompatible Zabbix version or malformed request.
fix
Ensure Zabbix server version matches py-zabbix supported versions; check API endpoint URL.
error AttributeError: module 'pyzabbix' has no attribute 'ZabbixSender' ↓
cause Older version of py-zabbix without ZabbixSender class.
fix
Upgrade py-zabbix to 1.1.3+ with 'pip install --upgrade py-zabbix'.
Warnings
gotcha Package name on PyPI has a hyphen (py-zabbix), but Python import uses underscore (pyzabbix). ↓
fix Use 'from pyzabbix import ...' (no hyphen).
deprecated Login method ZabbixAPI.login() accepts username and password in plain text; API tokens not natively supported in older versions. ↓
fix Use ZabbixAPI(token='...') constructor parameter if available (v1.1.7+).
gotcha ZabbixSender must have correct chunk_size for large data. Default may cause errors. ↓
fix Explicitly set chunk_size when creating ZabbixSender object.
Imports
- ZabbixAPI wrong
from py_zabbix import ZabbixAPIcorrectfrom pyzabbix import ZabbixAPI - ZabbixMetric
from pyzabbix import ZabbixMetric - ZabbixSender
from pyzabbix import ZabbixSender
Quickstart
from pyzabbix import ZabbixAPI
zapi = ZabbixAPI('http://zabbix.example.com')
zapi.login('user', 'password')
print('Connected to Zabbix API version %s' % zapi.api_version())