Skip to main content

Python module to work with zabbix.

Project description

|Build Status| |Coverage| |PyPi status| |PyPi version|

Zabbix module for Python


You can install Zabbix modules for Python with pip:


pip install py-zabbix

Official documentation for py-zabbix <>__



.. code:: python

    from pyzabbix.api import ZabbixAPI

    # Create ZabbixAPI class instance
    zapi = ZabbixAPI(url='https://localhost/zabbix/', user='Admin', password='zabbix')

    # Get all monitored hosts
    result1 =, output='extend')

    # Get all disabled hosts
    result2 = zapi.do_request('host.get',
                                  'filter': {'status': 1},
                                  'output': 'extend'

    # Filter results
    hostnames1 = [host['host'] for host in result1]
    hostnames2 = [host['host'] for host in result2['result']]

    # Logout from Zabbix

Or use 'with' statement to logout automatically:

.. code:: python

    from pyzabbix.api import ZabbixAPI

    # Create ZabbixAPI class instance
    with ZabbixAPI(url='https://localhost/zabbix/', user='Admin', password='zabbix') as zapi:

        # Get all monitored hosts
        result1 =, output='extend')

Enable logging:

.. code:: python

    import sys
    import logging
    from pyzabbix.api import ZabbixAPI

    # Create ZabbixAPI class instance
    logger = logging.getLogger("pyzabbix")
    handler = logging.StreamHandler(sys.stdout)

    zapi = ZabbixAPI(url='http://localhost', user='Admin', password='zabbix')

Note that passwords and auth tokens are hidden when raw messages are logged or raised in exceptions ( but not hidden if print() is used):

.. code:: python

    Call user.login method
    urllib2.Request(http://localhost/api_jsonrpc.php, {"jsonrpc": "2.0", "method": "user.login", "params": {"user": "Admin", "password": "********"}, "id": "1"})
    Response Body: {
        "jsonrpc": "2.0",
        "result": "********",
        "id": "1"


.. code:: python

from pyzabbix import ZabbixMetric, ZabbixSender

# Send metrics to zabbix trapper
packet = [
  ZabbixMetric('hostname1', 'test[cpu_usage]', 2),
  ZabbixMetric('hostname1', 'test[system_status]', "OK"),
  ZabbixMetric('hostname1', 'test[disk_io]', '0.1'),
  ZabbixMetric('hostname1', 'test[cpu_usage]', 20, 1411598020),

result = ZabbixSender(use_config=True).send(packet)

.. |Build Status| image:: :target: .. |Coverage| image:: :target: .. |PyPi status| image:: :target: .. |PyPi version| image:: :target:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-zabbix-1.1.7.tar.gz (11.4 kB view hashes)

Uploaded source

Built Distributions

py_zabbix-1.1.7-py3-none-any.whl (19.9 kB view hashes)

Uploaded py3

py_zabbix-1.1.7-py2-none-any.whl (19.9 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page