Skip to main content

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

Zabbix module for Python

Install

You can install Zabbix modules for Python with pip:

::

pip install py-zabbix

Official documentation for py-zabbix <https://py-zabbix.readthedocs.org/en/latest/>__

Examples

ZabbixAPI


.. 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 = zapi.host.get(monitored_hosts=1, 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
    zapi.user.logout()

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 = zapi.host.get(monitored_hosts=1, output='extend')

Enable logging:

.. code:: python

    import sys
    import logging
    from pyzabbix.api import ZabbixAPI

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

    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

    ZabbixAPI.login(Admin,********)
    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"
    }


ZabbixSender

.. 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:: https://travis-ci.org/adubkov/py-zabbix.svg?branch=master :target: https://travis-ci.org/adubkov/py-zabbix .. |Coverage| image:: https://coveralls.io/repos/github/adubkov/py-zabbix/badge.svg?branch=master :target: https://coveralls.io/github/adubkov/py-zabbix?branch=master .. |PyPi status| image:: https://img.shields.io/pypi/status/py-zabbix.svg :target: https://pypi.python.org/pypi/py-zabbix/ .. |PyPi version| image:: https://img.shields.io/pypi/v/py-zabbix.svg :target: https://pypi.python.org/pypi/py-zabbix/

Release files for py-zabbix 1.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-zabbix 1.1.7
File Size Uploaded
py-zabbix-1.1.7.tar.gz 11.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for py-zabbix 1.1.7
File Interpreter ABI Platform
py_zabbix-1.1.7-py3-none-any.whl Python 3 none any Details
py_zabbix-1.1.7-py2-none-any.whl Python 2 none any Details

Total release size: 51.3 kB

Release files / py-zabbix-1.1.7.tar.gz

Download URL py-zabbix-1.1.7.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0176569e61b134a9e445d9086cdfe895583ffe938f34deea3a9cffa78011e459
BLAKE2b-256 checksum
How to use checksums
c8b15ecb05b542a78dd6d619c825740fc11b12cb2afd06b9c679129a5c795554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

Release files / py_zabbix-1.1.7-py3-none-any.whl

Download URL py_zabbix-1.1.7-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f921abc88298c56f5aab9054815122ca959f8612df88fdc3a240ad2d95e4c282
BLAKE2b-256 checksum
How to use checksums
2227b75d1433caf55d077efe0dfadf494a53000bfc4ea5a1c9f197a87a3cd428
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

Release files / py_zabbix-1.1.7-py2-none-any.whl

Download URL py_zabbix-1.1.7-py2-none-any.whl
Size 19.9 kB
Tags Python 2
SHA-256 checksum
How to use checksums
40d1555d448ed05462764172894a8a3d97ba11e7b61e5f402f7180fe233899e1
BLAKE2b-256 checksum
How to use checksums
7ee31ce714213be26e5046b152ae9eb3ab0e5570cad33db73f714a73fdb74dc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

Release history Release notifications | RSS feed

This release

1.1.7 This release

3 release files

1.1.6

3 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.6

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page