Asynchronous Zabbix API Python interface
Project description
aiozabbix
aiozabbix is a Python package that provides an asynchronous interface to the Zabbix API, using aiohttp. It is based on PyZabbix.
Example usage
The interface mimics PyZabbix as closely as possible:
import asyncio
from aiozabbix import ZabbixAPI
async def main():
zapi = ZabbixAPI('https://zabbixserver.example.com/zabbix')
await zapi.login('zabbix user')
hosts = await zapi.host.get(output=['host', 'hostid', 'name', 'status'])
print(hosts)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
To customize the HTTP requests, for example to perform HTTP basic
authentication, you need to provide your own aiohttp.ClientSession
:
import asyncio
import aiohttp
from aiozabbix import ZabbixAPI
async def main():
auth = aiohttp.BasicAuth('zabbix user', password='zabbix password')
async with aiohttp.ClientSession(auth=auth) as session:
zapi = ZabbixAPI('https://zabbixserver.example.com/zabbix', client_session=session)
await zapi.login('zabbix user')
hosts = await zapi.host.get(output=['host', 'hostid', 'name', 'status'])
print(hosts)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
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
aiozabbix-1.3.0.tar.gz
(16.2 kB
view hashes)
Built Distribution
aiozabbix-1.3.0-py3-none-any.whl
(17.0 kB
view hashes)
Close
Hashes for aiozabbix-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1df91149afa00ce9a989cd415d99d151e11f162d1f5dc38f4e2955438280a62 |
|
MD5 | 93b77bf42a4ac7d1ad70d9c2563de545 |
|
BLAKE2b-256 | 2d66be70a084571250a631617ba40f47a8517e5faf8475d2bd9e1f7c683048c1 |