Initial commit
This commit is contained in:
51
debug_snmp.py
Normal file
51
debug_snmp.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import asyncio
|
||||
from utils.snmp import _snmp_walk_async, SnmpEngine, CommunityData, UdpTransportTarget, ContextData, ObjectType, ObjectIdentity, get_cmd
|
||||
|
||||
async def _snmp_get_async(host, community, oid):
|
||||
snmp_engine = SnmpEngine()
|
||||
community_data = CommunityData(community, mpModel=1)
|
||||
# Using larger timeout/retries just in case
|
||||
transport = await UdpTransportTarget.create((host, 161), timeout=2, retries=1)
|
||||
context = ContextData()
|
||||
|
||||
iterator = get_cmd(
|
||||
snmp_engine,
|
||||
community_data,
|
||||
transport,
|
||||
context,
|
||||
ObjectType(ObjectIdentity(oid))
|
||||
)
|
||||
|
||||
errorIndication, errorStatus, errorIndex, varBinds = await iterator
|
||||
snmp_engine.closeDispatcher()
|
||||
|
||||
if errorIndication or errorStatus:
|
||||
return None
|
||||
return str(varBinds[0][1])
|
||||
|
||||
async def main():
|
||||
host = "10.186.203.14"
|
||||
community = "public"
|
||||
|
||||
# Hypothesis: Slot 6, Port 1
|
||||
# 0x06A00000 = 111149056
|
||||
|
||||
targets = [
|
||||
(5, 1, 94371840), # Validated
|
||||
(6, 1, 111149056), # To Evaluate
|
||||
(6, 2, 111149056 + 65536)
|
||||
]
|
||||
|
||||
base_oid_prefix = "1.3.6.1.2.1.2.2.1.2" # ifDescr
|
||||
|
||||
for slot, port, if_index in targets:
|
||||
oid = f"{base_oid_prefix}.{if_index}"
|
||||
print(f"Checking Slot {slot} Port {port} (ID={if_index})...")
|
||||
val = await _snmp_get_async(host, community, oid)
|
||||
if val and "No Such" not in val:
|
||||
print(f" MATCH: {val}")
|
||||
else:
|
||||
print(f" FAIL: {val}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user