$# pip show pysnmp
Name: pysnmp
Version: 7.1.16
$:/etc/zabbix# pip show cryptography
Name: cryptography
Version: 42.0.5
$# pip show pycryptodome
Name: pycryptodome
Version: 3.21.0
import asyncio
from pysnmp.hlapi.v3arch.asyncio import *
async def main():
iterator = get_cmd(
SnmpEngine(),
UsmUserData(
'admin',
authKey='privateprivate',
privKey='privateprivate',
authProtocol=usmHMACMD5AuthProtocol,
privProtocol=usmDESPrivProtocol
),
await UdpTransportTarget.create(("10.20.7.108", 161)),
ContextData(),
ObjectType(ObjectIdentity('1.3.6.1.4.1.248.11.22.1.8.10.2.0')),
)
errorIndication, errorStatus, errorIndex, varBinds = await iterator
print(f"Error Indication: {errorIndication}, Error Status: {errorStatus}, Error Index: {errorIndex}")
print(f"VarBinds: {varBinds}")
if __name__ == '__main__':
try:
asyncio.run(main())
except RuntimeError:
pass # to avoid RuntimeError: Event loop is closed
print('out')
输出为
Error Indication: Ciphering services not available, Error Status: 0, Error Index: 0
VarBinds: ()
out
您正在使用旧版本
cryptography
。如果您升级到43.0.x版本,则情况应该很好,https://github.com/lextudio/pysnmp/blob/v7.1.16/pyproject.toml#l53