Library for async SNMP queries
Project description
Python Async SNMP Library
Installation
pip install asyncsnmplib
Example
from asyncsnmplib.client import Snmp
async def main():
oid = (1, 3, 6, 1, 2, 1, 1, 1, 0)
host = '127.0.0.1'
community = 'public'
cl = Snmp(host, community=community)
await cl.connect()
# GET
res = await cl.get(oid)
oid, tag, value = res
print(f'OID: {oid}\nTAG: {tag}\nVALUE: {value}')
# GETNEXT
res = await cl.get_next(oid)
oid, tag, value = res
print(f'OID: {oid}\nTAG: {tag}\nVALUE: {value}')
# GETBULK
varbinds = await cl.get_bulk(oid, max_repetitions=20)
for oid, tag, value in varbinds:
print(f'OID: {oid} | TAG: {tag} | VALUE: {value}')
# walk an OID tree
varbinds = await cl.walk(oid)
for oid, value in varbinds:
print(f'OID: {oid} | VALUE: {value}')
cl.close()
if __name__ == '__main__':
logger = logging.getLogger('asyncsnmplib')
logger.setLevel(logging.DEBUG)
asyncio.run(main())
Example SNMPv3
from asyncsnmplib.client import SnmpV3
from asyncsnmplib.v3.auth import USM_AUTH_HMAC96_SHA
from asyncsnmplib.v3.encr import USM_PRIV_CFB128_AES
async def main():
oid = (1, 3, 6, 1, 2, 1, 1, 1, 0)
host = '127.0.0.1'
username = 'User'
auth = (USM_AUTH_HMAC96_SHA, 'Password1')
priv = (USM_PRIV_CFB128_AES, 'Password2')
cl = SnmpV3(host, username=username, auth=auth, priv=priv)
await cl.connect()
# GET
res = await cl.get(oid)
oid, tag, value = res
print(f'OID: {oid}\nTAG: {tag}\nVALUE: {value}')
cl.close()
if __name__ == '__main__':
logger = logging.getLogger('asyncsnmplib')
logger.setLevel(logging.DEBUG)
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asyncsnmplib-1.0.11.tar.gz
(34.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asyncsnmplib-1.0.11.tar.gz.
File metadata
- Download URL: asyncsnmplib-1.0.11.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f12c99b0640c694c3d74a7ef5b4ecf4add190fbcfe5faa39d7be39977972a5d
|
|
| MD5 |
c70d1014a828b8be5e50407e919ee335
|
|
| BLAKE2b-256 |
cf018cdd41f75b2b0a6344ca8aebade6527b9e9d4c81787a2c7791c596a6e9c9
|
File details
Details for the file asyncsnmplib-1.0.11-py3-none-any.whl.
File metadata
- Download URL: asyncsnmplib-1.0.11-py3-none-any.whl
- Upload date:
- Size: 39.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53342dc82ee32a6165dffc45d65b5badc6de73f24ad0fcd468d85b3a26f21f8a
|
|
| MD5 |
1be5a285ae7af661ef8f306688d1a0cb
|
|
| BLAKE2b-256 |
3db4f5691406cbce8f2fc98272b3c9ec3e72252f62ce34740b86c85e5b7c0478
|