# Zabbix utils library
[![Tests](https://github.com/zabbix/python-zabbix-utils/actions/workflows/tests.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/tests.yaml)
[![Zabbix API](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_api.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_api.yaml)
[![Zabbix sender](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_sender.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_sender.yaml)
[![Zabbix get](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_getter.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_getter.yaml)
[![Zabbix 5.0](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_50.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_50.yaml)
[![Zabbix 6.0](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_60.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_60.yaml)
[![Zabbix 6.4](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_64.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_64.yaml)
[![Zabbix 7.0](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_70.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_70.yaml)
**zabbix_utils** is a Python library for working with [Zabbix API](https://www.zabbix.com/documentation/current/manual/api/reference) as well as with [Zabbix sender](https://www.zabbix.com/documentation/current/manpages/zabbix_sender) and [Zabbix get](https://www.zabbix.com/documentation/current/manpages/zabbix_get) protocols.
## Requirements
Supported versions:
* Zabbix 5.0+
* Python 3.8+
Tested on:
* Zabbix 5.0, 6.0, 6.4 and 7.0
* Python 3.8, 3.9, 3.10, 3.11 and 3.12
Dependencies:
* [aiohttp](https://github.com/aio-libs/aiohttp) (in case of async use)
## Installation
### Installation from PyPI
Install **zabbix_utils** library using pip:
```bash
$ pip install zabbix_utils
```
To install the library with dependencies for asynchronous work use the following way:
```bash
$ pip install zabbix_utils[async]
```
### Installation from Zabbix repository
First of all, you need to install Zabbix repository. Official Zabbix packages for Red Hat Enterprise Linux and derivatives, as well as for Debian and derivatives are available on [Zabbix website](https://www.zabbix.com/download).
**Red Hat Enterprise Linux and derivatives**
Install **zabbix_utils** library from Zabbix repository:
```bash
# dnf install python3-zabbix-utils
```
To install additional dependencies such as aiohttp for asynchronous work use the following way:
```bash
# dnf install epel-release
# dnf install python3-aiohttp
```
**Debian / Ubuntu and derivatives**
Install **zabbix_utils** library from Zabbix repository:
```bash
# apt install python3-zabbix-utils
```
To install additional dependencies such as aiohttp for asynchronous work use the following way:
```bash
# apt install python3-aiohttp
```
### Installation from GitHub
Clone the **zabbix_utils** repository:
```bash
$ git clone https://github.com/zabbix/python-zabbix-utils
```
Install **zabbix_utils** library using setup.py:
```bash
$ cd python-zabbix-utils/
$ python3 setup.py install
```
To install dependencies use one of the ways above.
## Documentation
### Use cases
##### To work with Zabbix API
To work with Zabbix API via synchronous I/O you can import and use **zabbix_utils** library as follows:
```python
from zabbix_utils import ZabbixAPI
api = ZabbixAPI(url="127.0.0.1")
api.login(user="User", password="zabbix")
users = api.user.get(
output=['userid','name']
)
for user in users:
print(user['name'])
api.logout()
```
To work with Zabbix API via asynchronous I/O you can use the following way:
```python
import asyncio
from zabbix_utils import AsyncZabbixAPI
async def main():
api = AsyncZabbixAPI(url="127.0.0.1")
await api.login(user="User", password="zabbix")
users = await api.user.get(
output=['userid','name']
)
for user in users:
print(user['name'])
await api.logout()
asyncio.run(main())
```
You can also authenticate using an API token (supported since Zabbix 5.4):
```python
api = ZabbixAPI(url="127.0.0.1")
api.login(token="xxxxxxxx")
```
```python
api = AsyncZabbixAPI(url="127.0.0.1")
await api.login(token="xxxxxxxx")
```
When token is used, calling `api.logout()` is not necessary.
It is possible to specify authentication fields by the following environment variables:
`ZABBIX_URL`, `ZABBIX_TOKEN`, `ZABBIX_USER`, `ZABBIX_PASSWORD`
You can compare Zabbix API version with strings and numbers, for example:
```python
# Method to get version
ver = api.api_version()
print(type(ver).__name__, ver) # APIVersion 7.0.0
# ZabbixAPI prototype with version
ver = api.version
print(type(ver).__name__, ver) # APIVersion 7.0.0
# Comparing versions
print(ver > 6.0) # True
print(ver != 7.0) # False
print(ver != "7.0.0") # False
# Version additional methods
print(ver.major) # 7.0
print(ver.minor) # 0
print(ver.is_lts()) # True
```
In case the API object or method name matches one of Python keywords, you can use the suffix `_` in their name to execute correctly, for example:
```python
from zabbix_utils import ZabbixAPI
api = ZabbixAPI(url="127.0.0.1")
api.login(token="xxxxxxxx")
template_source = ''
with open('template_example.xml', mode='r', encoding='utf-8') as f:
template_source = f.read()
response = api.configuration.import_(
source=template_source,
format="xml",
rules={...}
)
if response:
print("Template imported successfully")
```
> Please, refer to the [Zabbix API Documentation](https://www.zabbix.com/documentation/current/manual/api/reference) and the [using examples](https://github.com/zabbix/python-zabbix-utils/tree/main/examples/api) for more information.
##### To work via Zabbix sender protocol
To send item values to a Zabbix server or a Zabbix proxy you can import and use the library as follows:
```python
from zabbix_utils import Sender
sender = Sender(server='127.0.0.1', port=10051)
response = sender.send_value('host', 'item.key', 'value', 1695713666)
print(response)
# {"processed": 1, "failed": 0, "total": 1, "time": "0.000338", "chunk": 1}
```
The asynchronous way:
```python
import asyncio
from zabbix_utils import AsyncSender
async def main():
sender = AsyncSender(server='127.0.0.1', port=10051)
response = await sender.send_value('host', 'item.key', 'value', 1695713666)
print(response)
# {"processed": 1, "failed": 0, "total": 1, "time": "0.000338", "chunk": 1}
asyncio.run(main())
```
You can also prepare a list of item values and send all at once:
```python
from zabbix_utils import ItemValue, Sender
items = [
ItemValue('host1', 'item.key1', 10),
ItemValue('host1', 'item.key2', 'test message'),
ItemValue('host2', 'item.key1', -1, 1695713666),
ItemValue('host3', 'item.key1', '{"msg":"test message"}'),
ItemValue('host2', 'item.key1', 0, 1695713666, 100)
]
sender = Sender(server='127.0.0.1', port=10051)
response = sender.send(items)
print(response)
# {"processed": 5, "failed": 0, "total": 5, "time": "0.001661", "chunk": 1}
```
If you need to send values to several Zabbix clusters at once, you can do this by passing a list of Zabbix clusters:
```python
from zabbix_utils import Sender
zabbix_clusters = [
['zabbix.cluster1.node1', 'zabbix.cluster1.node2:10051'],
['zabbix.cluster2.node1:10051', 'zabbix.cluster2.node2:20051', 'zabbix.cluster2.node3']
]
sender = Sender(clusters=zabbix_clusters)
response = sender.send_value('host', 'item.key', 'value', 1695713666)
print(response)
# {"processed": 2, "failed": 0, "total": 2, "time": "0.000103", "chunk": 2}
print(response.details)
# {
# zabbix.cluster1.node1:10051: [{"processed": 1, "failed": 0, "total": 1, "time": "0.000050", "chunk": 1}],
# zabbix.cluster2.node2:20051: [{"processed": 1, "failed": 0, "total": 1, "time": "0.000053", "chunk": 1}]
# }
```
In such case, the value will be sent to the first available node of each cluster.
> Please, refer to the [Zabbix sender protocol](https://www.zabbix.com/documentation/current/manual/appendix/protocols/zabbix_sender) and the [using examples](https://github.com/zabbix/python-zabbix-utils/tree/main/examples/sender) for more information.
##### To work via Zabbix get protocol
To get a value by item key from a Zabbix agent or agent 2 via synchronous I/O the library can be imported and used as follows:
```python
from zabbix_utils import Getter
agent = Getter(host='127.0.0.1', port=10050)
resp = agent.get('system.uname')
print(resp.value)
# Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
```
The library can be used via asynchronous I/O, as in the following example:
```python
import asyncio
from zabbix_utils import AsyncGetter
async def main():
agent = AsyncGetter(host='127.0.0.1', port=10050)
resp = await agent.get('system.uname')
print(resp.value)
# Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
asyncio.run(main())
```
> Please, refer to the [Zabbix agent protocol](https://www.zabbix.com/documentation/current/manual/appendix/protocols/zabbix_agent) and the [using examples](https://github.com/zabbix/python-zabbix-utils/tree/main/examples/get) for more information.
### Enabling debug log
If it needed to debug some issue with Zabbix API, sender or get you can enable the output of logging. The **zabbix_utils** library uses the default python logging module, but it doesn't log by default. You can define logging handler to see records from the library, for example:
```python
import logging
from zabbix_utils import Getter
logging.basicConfig(
format=u'[%(asctime)s] %(levelname)s %(message)s',
level=logging.DEBUG
)
agent = Getter(host='127.0.0.1', port=10050)
resp = agent.get('system.uname')
print(resp.value)
```
And then you can see records like the following:
```
[2023-10-01 12:00:01,587] DEBUG Content of the packet: b'ZBXD\x01\x0c\x00\x00\x00\x00\x00\x00\x00system.uname'
[2023-10-01 12:00:01,722] DEBUG Zabbix response header: b'ZBXD\x01C\x00\x00\x00C\x00\x00\x00'
[2023-10-01 12:00:01,723] DEBUG Zabbix response body: Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
[2023-10-01 12:00:01,724] DEBUG Response from [127.0.0.1:10050]: Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
```
## License
**zabbix_utils** is distributed under MIT License.
Raw data
{
"_id": null,
"home_page": "https://github.com/zabbix/python-zabbix-utils",
"name": "zabbix-utils",
"maintainer": "Aleksandr Iantsen",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "aleksandr.iantsen@zabbix.com",
"keywords": "monitoring zabbix api sender get utils tools",
"author": "Zabbix SIA",
"author_email": "integrationteam@zabbix.com",
"download_url": "https://files.pythonhosted.org/packages/d4/b7/d189354bacf2bca0429c89b5fd833657a869b0a42d2b372e498b47ccfb2a/zabbix_utils-2.0.1.tar.gz",
"platform": null,
"description": "# Zabbix utils library\r\n\r\n[![Tests](https://github.com/zabbix/python-zabbix-utils/actions/workflows/tests.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/tests.yaml)\r\n[![Zabbix API](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_api.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_api.yaml)\r\n[![Zabbix sender](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_sender.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_sender.yaml)\r\n[![Zabbix get](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_getter.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_getter.yaml)\r\n\r\n[![Zabbix 5.0](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_50.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_50.yaml)\r\n[![Zabbix 6.0](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_60.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_60.yaml)\r\n[![Zabbix 6.4](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_64.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_64.yaml)\r\n[![Zabbix 7.0](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_70.yaml/badge.svg)](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_70.yaml)\r\n\r\n**zabbix_utils** is a Python library for working with [Zabbix API](https://www.zabbix.com/documentation/current/manual/api/reference) as well as with [Zabbix sender](https://www.zabbix.com/documentation/current/manpages/zabbix_sender) and [Zabbix get](https://www.zabbix.com/documentation/current/manpages/zabbix_get) protocols.\r\n\r\n## Requirements\r\n\r\nSupported versions:\r\n\r\n* Zabbix 5.0+\r\n* Python 3.8+\r\n\r\nTested on:\r\n\r\n* Zabbix 5.0, 6.0, 6.4 and 7.0\r\n* Python 3.8, 3.9, 3.10, 3.11 and 3.12\r\n\r\nDependencies:\r\n\r\n* [aiohttp](https://github.com/aio-libs/aiohttp) (in case of async use)\r\n\r\n## Installation\r\n\r\n### Installation from PyPI\r\n\r\nInstall **zabbix_utils** library using pip:\r\n\r\n```bash\r\n$ pip install zabbix_utils\r\n```\r\n\r\nTo install the library with dependencies for asynchronous work use the following way:\r\n\r\n```bash\r\n$ pip install zabbix_utils[async]\r\n```\r\n\r\n### Installation from Zabbix repository\r\n\r\nFirst of all, you need to install Zabbix repository. Official Zabbix packages for Red Hat Enterprise Linux and derivatives, as well as for Debian and derivatives are available on [Zabbix website](https://www.zabbix.com/download).\r\n\r\n**Red Hat Enterprise Linux and derivatives**\r\n\r\nInstall **zabbix_utils** library from Zabbix repository:\r\n\r\n```bash\r\n# dnf install python3-zabbix-utils\r\n```\r\n\r\nTo install additional dependencies such as aiohttp for asynchronous work use the following way:\r\n```bash\r\n# dnf install epel-release\r\n# dnf install python3-aiohttp\r\n```\r\n\r\n**Debian / Ubuntu and derivatives**\r\n\r\nInstall **zabbix_utils** library from Zabbix repository:\r\n\r\n```bash\r\n# apt install python3-zabbix-utils\r\n```\r\n\r\nTo install additional dependencies such as aiohttp for asynchronous work use the following way:\r\n```bash\r\n# apt install python3-aiohttp\r\n```\r\n\r\n### Installation from GitHub\r\n\r\nClone the **zabbix_utils** repository:\r\n\r\n```bash\r\n$ git clone https://github.com/zabbix/python-zabbix-utils\r\n```\r\n\r\nInstall **zabbix_utils** library using setup.py:\r\n\r\n```bash\r\n$ cd python-zabbix-utils/\r\n$ python3 setup.py install\r\n```\r\n\r\nTo install dependencies use one of the ways above.\r\n\r\n## Documentation\r\n\r\n### Use cases\r\n\r\n##### To work with Zabbix API\r\n\r\nTo work with Zabbix API via synchronous I/O you can import and use **zabbix_utils** library as follows:\r\n\r\n```python\r\nfrom zabbix_utils import ZabbixAPI\r\n\r\napi = ZabbixAPI(url=\"127.0.0.1\")\r\napi.login(user=\"User\", password=\"zabbix\")\r\n\r\nusers = api.user.get(\r\n output=['userid','name']\r\n)\r\n\r\nfor user in users:\r\n print(user['name'])\r\n\r\napi.logout()\r\n```\r\n\r\nTo work with Zabbix API via asynchronous I/O you can use the following way:\r\n\r\n```python\r\nimport asyncio\r\nfrom zabbix_utils import AsyncZabbixAPI\r\n\r\nasync def main():\r\n api = AsyncZabbixAPI(url=\"127.0.0.1\")\r\n await api.login(user=\"User\", password=\"zabbix\")\r\n\r\n users = await api.user.get(\r\n output=['userid','name']\r\n )\r\n\r\n for user in users:\r\n print(user['name'])\r\n\r\n await api.logout()\r\n\r\nasyncio.run(main())\r\n```\r\n\r\nYou can also authenticate using an API token (supported since Zabbix 5.4):\r\n\r\n```python\r\napi = ZabbixAPI(url=\"127.0.0.1\")\r\napi.login(token=\"xxxxxxxx\")\r\n```\r\n\r\n```python\r\napi = AsyncZabbixAPI(url=\"127.0.0.1\")\r\nawait api.login(token=\"xxxxxxxx\")\r\n```\r\n\r\nWhen token is used, calling `api.logout()` is not necessary.\r\n\r\nIt is possible to specify authentication fields by the following environment variables:\r\n`ZABBIX_URL`, `ZABBIX_TOKEN`, `ZABBIX_USER`, `ZABBIX_PASSWORD`\r\n\r\nYou can compare Zabbix API version with strings and numbers, for example:\r\n\r\n```python\r\n# Method to get version\r\nver = api.api_version()\r\nprint(type(ver).__name__, ver) # APIVersion 7.0.0\r\n\r\n# ZabbixAPI prototype with version\r\nver = api.version\r\nprint(type(ver).__name__, ver) # APIVersion 7.0.0\r\n\r\n# Comparing versions\r\nprint(ver > 6.0) # True\r\nprint(ver != 7.0) # False\r\nprint(ver != \"7.0.0\") # False\r\n\r\n# Version additional methods\r\nprint(ver.major) # 7.0\r\nprint(ver.minor) # 0\r\nprint(ver.is_lts()) # True\r\n```\r\n\r\nIn case the API object or method name matches one of Python keywords, you can use the suffix `_` in their name to execute correctly, for example:\r\n```python\r\nfrom zabbix_utils import ZabbixAPI\r\n\r\napi = ZabbixAPI(url=\"127.0.0.1\")\r\napi.login(token=\"xxxxxxxx\")\r\n\r\ntemplate_source = ''\r\nwith open('template_example.xml', mode='r', encoding='utf-8') as f:\r\n template_source = f.read()\r\n\r\nresponse = api.configuration.import_(\r\n source=template_source,\r\n format=\"xml\",\r\n rules={...}\r\n)\r\n\r\nif response:\r\n print(\"Template imported successfully\")\r\n```\r\n\r\n> Please, refer to the [Zabbix API Documentation](https://www.zabbix.com/documentation/current/manual/api/reference) and the [using examples](https://github.com/zabbix/python-zabbix-utils/tree/main/examples/api) for more information.\r\n\r\n##### To work via Zabbix sender protocol\r\n\r\nTo send item values to a Zabbix server or a Zabbix proxy you can import and use the library as follows:\r\n\r\n```python\r\nfrom zabbix_utils import Sender\r\n\r\nsender = Sender(server='127.0.0.1', port=10051)\r\nresponse = sender.send_value('host', 'item.key', 'value', 1695713666)\r\n\r\nprint(response)\r\n# {\"processed\": 1, \"failed\": 0, \"total\": 1, \"time\": \"0.000338\", \"chunk\": 1}\r\n```\r\n\r\nThe asynchronous way:\r\n\r\n```python\r\nimport asyncio\r\nfrom zabbix_utils import AsyncSender\r\n\r\nasync def main():\r\n sender = AsyncSender(server='127.0.0.1', port=10051)\r\n response = await sender.send_value('host', 'item.key', 'value', 1695713666)\r\n\r\n print(response)\r\n # {\"processed\": 1, \"failed\": 0, \"total\": 1, \"time\": \"0.000338\", \"chunk\": 1}\r\n\r\nasyncio.run(main())\r\n```\r\n\r\nYou can also prepare a list of item values and send all at once:\r\n\r\n```python\r\nfrom zabbix_utils import ItemValue, Sender\r\n\r\nitems = [\r\n ItemValue('host1', 'item.key1', 10),\r\n ItemValue('host1', 'item.key2', 'test message'),\r\n ItemValue('host2', 'item.key1', -1, 1695713666),\r\n ItemValue('host3', 'item.key1', '{\"msg\":\"test message\"}'),\r\n ItemValue('host2', 'item.key1', 0, 1695713666, 100)\r\n]\r\n\r\nsender = Sender(server='127.0.0.1', port=10051)\r\nresponse = sender.send(items)\r\n\r\nprint(response)\r\n# {\"processed\": 5, \"failed\": 0, \"total\": 5, \"time\": \"0.001661\", \"chunk\": 1}\r\n```\r\n\r\nIf you need to send values to several Zabbix clusters at once, you can do this by passing a list of Zabbix clusters:\r\n\r\n```python\r\nfrom zabbix_utils import Sender\r\n\r\nzabbix_clusters = [\r\n ['zabbix.cluster1.node1', 'zabbix.cluster1.node2:10051'],\r\n ['zabbix.cluster2.node1:10051', 'zabbix.cluster2.node2:20051', 'zabbix.cluster2.node3']\r\n]\r\n\r\nsender = Sender(clusters=zabbix_clusters)\r\nresponse = sender.send_value('host', 'item.key', 'value', 1695713666)\r\n\r\nprint(response)\r\n# {\"processed\": 2, \"failed\": 0, \"total\": 2, \"time\": \"0.000103\", \"chunk\": 2}\r\n\r\nprint(response.details)\r\n# {\r\n# zabbix.cluster1.node1:10051: [{\"processed\": 1, \"failed\": 0, \"total\": 1, \"time\": \"0.000050\", \"chunk\": 1}],\r\n# zabbix.cluster2.node2:20051: [{\"processed\": 1, \"failed\": 0, \"total\": 1, \"time\": \"0.000053\", \"chunk\": 1}]\r\n# }\r\n```\r\n\r\nIn such case, the value will be sent to the first available node of each cluster.\r\n\r\n> Please, refer to the [Zabbix sender protocol](https://www.zabbix.com/documentation/current/manual/appendix/protocols/zabbix_sender) and the [using examples](https://github.com/zabbix/python-zabbix-utils/tree/main/examples/sender) for more information.\r\n\r\n##### To work via Zabbix get protocol\r\n\r\nTo get a value by item key from a Zabbix agent or agent 2 via synchronous I/O the library can be imported and used as follows:\r\n\r\n```python\r\nfrom zabbix_utils import Getter\r\n\r\nagent = Getter(host='127.0.0.1', port=10050)\r\nresp = agent.get('system.uname')\r\n\r\nprint(resp.value)\r\n# Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64\r\n```\r\n\r\nThe library can be used via asynchronous I/O, as in the following example:\r\n\r\n```python\r\nimport asyncio\r\nfrom zabbix_utils import AsyncGetter\r\n\r\nasync def main():\r\n agent = AsyncGetter(host='127.0.0.1', port=10050)\r\n resp = await agent.get('system.uname')\r\n\r\n print(resp.value)\r\n # Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n> Please, refer to the [Zabbix agent protocol](https://www.zabbix.com/documentation/current/manual/appendix/protocols/zabbix_agent) and the [using examples](https://github.com/zabbix/python-zabbix-utils/tree/main/examples/get) for more information.\r\n\r\n### Enabling debug log\r\n\r\nIf it needed to debug some issue with Zabbix API, sender or get you can enable the output of logging. The **zabbix_utils** library uses the default python logging module, but it doesn't log by default. You can define logging handler to see records from the library, for example:\r\n\r\n```python\r\nimport logging\r\nfrom zabbix_utils import Getter\r\n\r\nlogging.basicConfig(\r\n format=u'[%(asctime)s] %(levelname)s %(message)s',\r\n level=logging.DEBUG\r\n)\r\n\r\nagent = Getter(host='127.0.0.1', port=10050)\r\nresp = agent.get('system.uname')\r\n\r\nprint(resp.value)\r\n```\r\n\r\nAnd then you can see records like the following:\r\n\r\n```\r\n[2023-10-01 12:00:01,587] DEBUG Content of the packet: b'ZBXD\\x01\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00system.uname'\r\n[2023-10-01 12:00:01,722] DEBUG Zabbix response header: b'ZBXD\\x01C\\x00\\x00\\x00C\\x00\\x00\\x00'\r\n[2023-10-01 12:00:01,723] DEBUG Zabbix response body: Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64\r\n[2023-10-01 12:00:01,724] DEBUG Response from [127.0.0.1:10050]: Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64\r\nLinux test_server 5.15.0-3.60.5.1.el9uek.x86_64\r\n\r\n```\r\n\r\n## License\r\n**zabbix_utils** is distributed under MIT License.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A library with modules for working with Zabbix (Zabbix API, Zabbix sender, Zabbix get)",
"version": "2.0.1",
"project_urls": {
"Bug Tracker": "https://github.com/zabbix/python-zabbix-utils/issues",
"Changes": "https://github.com/zabbix/python-zabbix-utils/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/zabbix/python-zabbix-utils",
"Source": "https://github.com/zabbix/python-zabbix-utils",
"Zabbix": "https://www.zabbix.com/documentation/current"
},
"split_keywords": [
"monitoring",
"zabbix",
"api",
"sender",
"get",
"utils",
"tools"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1c3782b882a016e3a4ab29985c55978a4d6c27fd5a4043f1101a3ca4af39bba5",
"md5": "5a5c39f2cfbbb817fdf4b7dd4df1e74f",
"sha256": "320c0d82633727e30711fb4153cf72595dee415d23e1bb1f2418fc26d647fab2"
},
"downloads": -1,
"filename": "zabbix_utils-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5a5c39f2cfbbb817fdf4b7dd4df1e74f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 37134,
"upload_time": "2024-09-18T10:40:44",
"upload_time_iso_8601": "2024-09-18T10:40:44.138604Z",
"url": "https://files.pythonhosted.org/packages/1c/37/82b882a016e3a4ab29985c55978a4d6c27fd5a4043f1101a3ca4af39bba5/zabbix_utils-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d4b7d189354bacf2bca0429c89b5fd833657a869b0a42d2b372e498b47ccfb2a",
"md5": "1480eb6e41c1c61faa71bbb80952c299",
"sha256": "fd7a9d0242ca2e543ddeab390a5fc38fce1c2c9efda06782f91423c9f2180201"
},
"downloads": -1,
"filename": "zabbix_utils-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1480eb6e41c1c61faa71bbb80952c299",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 27541,
"upload_time": "2024-09-18T10:40:46",
"upload_time_iso_8601": "2024-09-18T10:40:46.505287Z",
"url": "https://files.pythonhosted.org/packages/d4/b7/d189354bacf2bca0429c89b5fd833657a869b0a42d2b372e498b47ccfb2a/zabbix_utils-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-18 10:40:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zabbix",
"github_project": "python-zabbix-utils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "aiohttp",
"specs": [
[
"<",
"4"
],
[
">=",
"3"
]
]
}
],
"lcname": "zabbix-utils"
}