Skip to main content

Zabbix sender

Dependency free implementation of the Zabbix Sender protocol using asyncio.

Key features:

  • Full specification implemented compared to other Zabbix sender implementations
  • Compression is enabled as default
  • Asynchronous implementation allows the program to continue while waiting for a response from Zabbix

Installation

The package can be found on PyPI and installed using pip:

pip install asyncio-zabbix-sender

Usage

The measurements for the Zabbix trapper item(s) can be sent using a high-level API. The Measurements object is a collection of measurements. The measurements can both be added via the constructor (as per the example below), but also dynamically via the add_measurement method.

import datetime
from asyncio_zabbix_sender import ZabbixSender, Measurements, Measurement

sender = ZabbixSender("example.com")

measurements = Measurements([
    Measurement(
        "vm-game-server", "cheat.used[doom,player1]", "idkfa", datetime.datetime.utcnow()
    )
])

response = await sender.send(measurements)

This package can also be used on a lower level to send packets directly.

from asyncio_zabbix_sender import create_packet, ZabbixSender

packet = create_packet(
    request=b'{"request":"sender data","data":[{"host":"<hostname>","key":"trap","value":"test value"}]}',
    use_compression=True
)

sender = ZabbixSender("example.com")
response = await sender.send_packet(packet)

Logging

The logger can be configured by using the name asyncio-zabbix-sender:

import logging

logger = logging.getLogger("asyncio-zabbix-sender")
logger.setLevel(logging.DEBUG)

Example from the test_send unit test by running pytest with --log-cli-level=DEBUG:

DEBUG    asyncio-zabbix-sender:_protocol.py:47 Compressed packet: 40 bytes. Original 35.
DEBUG    asyncio-zabbix-sender:_zabbix_sender.py:63 Created packet from measurements. Used compression: True.
DEBUG    asyncio-zabbix-sender:_zabbix_sender.py:78 Sending packet: b'ZBXD\x03(\x00\x00\x00#\x00\x00\x00x\x9c\xabVJI,IT\xb2\x8a\x8e\xd5Q*J-,M-.Q\xb2R*N\xcdKI-R\x00K\xd5\x02\x00\xd3\xc2\x0b\xfb'
DEBUG    asyncio-zabbix-sender:_zabbix_sender.py:84 Got response: b'x\x9c\x15\xc8\xc1\n\x80 \x0c\x00\xd0_\x19;G\xa0\xd9!\xfd\x1a\xd1\t\x82l\xe2\xec\x14\xfd{y{\xbc\x07\x07i\x17VB\x0f\xa8wJ\xa4\x8a\x1b`\xe5"\xab\xfa\x90U\x94=8\x13\xa0\xc4\xda\x96m\x80)3\xb6\x7f\x8f\x00JI8+h\'\x9e\x1e\x0e\xb3;s^\x16\xdf\x0f\xc8\xd6\x1d\xb5'
INFO     asyncio-zabbix-sender:_zabbix_sender.py:87 Packet sent: 53 bytes. Response data received: 88 bytes. Response flags 3.
DEBUG    asyncio-zabbix-sender:_zabbix_sender.py:97 Parsed response payload: {'response': 'success', 'info': 'processed: 41; failed: 2; total: 43; seconds spent: 31.41592'}

Note that only a summary of the packet that are send and the response received are logged as informational. Everything else is logged at debug level.

The INFO log entry contains the response flags. A response flag are set by:

  • 0x01 - Zabbix communications protocol
  • 0x02 - If compression is used
  • 0x04 - If the response is a large packet

Road map

The following improvements are planned (not necessary in order):

  • Better error handling
  • More documentation (how to set up ssl among other things)

Metadata

Release files for asyncio-zabbix-sender 0.2.1

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

Source distribution (sdist)

Source distribution for asyncio-zabbix-sender 0.2.1
File Size Uploaded Provenance Actions
asyncio_zabbix_sender-0.2.1.tar.gz 11.6 kB Without provenance Details for asyncio_zabbix_sender-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for asyncio-zabbix-sender 0.2.1
File Interpreter ABI Platform Actions
asyncio_zabbix_sender-0.2.1-py3-none-any.whl Python 3 none any Details for asyncio_zabbix_sender-0.2.1-py3-none-any.whl

Total release size: 25.5 kB

Release files / asyncio_zabbix_sender-0.2.1.tar.gz

Download URL asyncio_zabbix_sender-0.2.1.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fb6afe9035bf6189ecd3d823a81beb8c687068b29cb513863ef5a61818088c6d
BLAKE2b-256 checksum
How to use checksums
c521602d2bd1766962bec5ced8c0ba2c5481848f8451b8eaf3b80f4f05562aac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.8.10 Linux/5.4.0-174-generic

Release files / asyncio_zabbix_sender-0.2.1-py3-none-any.whl

Download URL asyncio_zabbix_sender-0.2.1-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3655aa21e2c0342f3975acf96c5d774f87ec7507cce18717e7f3a06b70227a94
BLAKE2b-256 checksum
How to use checksums
12df926f11811d1cd7eddc55f132c420a3529f4e41176dc7f55df019b6cbf91a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.8.10 Linux/5.4.0-174-generic

Security for asyncio-zabbix-sender 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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