Got 3750-X monitoring working

This commit is contained in:
2026-03-17 19:38:27 +01:00
parent c474f9c9c2
commit e66998b826
9 changed files with 424 additions and 132 deletions

View File

@@ -20,14 +20,6 @@ if not SNMPUSER or not SNMPPRIVKEY or not SNMPAUTHKEY:
raise Exception("No SNMP user or/and PrivAuth passed")
# SNMP
USMUSRDATA = UsmUserData(
userName=SNMPUSER,
authKey=SNMPAUTHKEY,
privKey=SNMPPRIVKEY,
authProtocol=usmHMACSHAAuthProtocol,
privProtocol=usmAesCfb128Protocol,
)
@@ -43,7 +35,23 @@ USMUSRDATA = UsmUserData(
# The value is always a string so it needs to be converted to int if needed
async def walk_column_v3(snmpEngine, remoteIP: str, base_oid: str) -> dict:
async def walk_column_v3(
snmpEngine,
remoteIP: str,
base_oid: str,
SNMPUSER: str,
SNMPAUTHKEY: str,
SNMPPRIVKEY: str
) -> dict:
# SNMP
USMUSRDATA = UsmUserData(
userName=SNMPUSER,
authKey=SNMPAUTHKEY,
privKey=SNMPPRIVKEY,
authProtocol=usmHMACSHAAuthProtocol,
privProtocol=usmAesCfb128Protocol,
)
rows = {}
async for errInd, errStat, errIdx, varBinds in walk_cmd(
snmpEngine,
@@ -66,4 +74,44 @@ async def walk_column_v3(snmpEngine, remoteIP: str, base_oid: str) -> dict:
idx = int(oid.prettyPrint().split(".")[-1])
rows[idx] = val.prettyPrint()
return rows
return rows
async def walk_lobotomy_column_v3(
snmpEngine,
remoteIP: str,
base_oid: str,
SNMPUSER: str,
SNMPAUTHKEY: str,
SNMPPRIVKEY: str
) -> list:
# SNMP
USMUSRDATA = UsmUserData(
userName=SNMPUSER,
authKey=SNMPAUTHKEY,
privKey=SNMPPRIVKEY,
authProtocol=usmHMACSHAAuthProtocol,
privProtocol=usmAesCfb128Protocol,
)
elements = []
async for errInd, errStat, errIdx, varBinds in walk_cmd(
snmpEngine,
USMUSRDATA,
await UdpTransportTarget.create((remoteIP, SNMPORT)),
ContextData(),
ObjectType(ObjectIdentity(base_oid)),
lexicographicMode=False,
):
if errInd:
print(f"\n\n{errInd}\n\n")
if "No SNMP response received before timeout" in str(errInd):
raise SNMPTimeoutError(f"Host {remoteIP} timed out while walking {base_oid}")
raise RuntimeError(errInd)
if errStat:
raise RuntimeError(errStat.prettyPrint())
for oid, val in varBinds:
elements.append(val.prettyPrint())
return elements