I was wondering if anyone has any ideas on what i'm goofing up. Essentially i am trying to fetch the entire mac table from a cisco switch using snmpv3. Apparently cisco sucks and you need to query each vlan individually unlike other vendors ... So my question is, How would i go about implementing that in pysnmp? I tried a few ways and they keep coming up with errors. Right now my working bulk command below works, but for the mac tables i need to figure out how to specify a vlan number which is where i'm having the most issues. Any help is appreciated.
The equivalent snmpv2c command is
snmpwalk -v2c -c letsconfigRO@10 10.0.0.101 1.3.6.1.2.1.17.4.3.1.1
My current iteration of a bulk command for pysnmp is
auth = cmdgen.UsmUserData(userName=snmpv3Username,
authKey=snmpv3Password,
authProtocol=authProtocol,
privKey=privKey,
privProtocol=privProtocol)
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.bulkCmd(
auth,
cmdgen.UdpTransportTarget((host, 161)),
0, 1000,
cmdgen.MibVariable(walk_oid),
lookupMib=False,
lexicographicMode=False
)
which works fine for normal walking as it does fetch the mac table, but only for vlan 1.
One of the latest ones i tried after this was
# Create SNMP engine instance
snmp_engine = SnmpEngine()
# Create SNMPv3 user data object
user = UsmUserData(userName=snmpv3Username,
authKey=snmpv3Password,
authProtocol=authProtocol,
privKey=privKey,
privProtocol=privProtocol)
# Define SNMPv3 target
target = UdpTransportTarget(('10.0.0.101', 161))
# Define VLAN ID
vlan_id = 10
# Define OID for retrieving MAC addresses for a specific VLAN
oid = ObjectType(ObjectIdentity('BRIDGE-MIB', 'dot1dTpFdbPort'))
# Define OID for retrieving VLAN membership information
vmVlan_oid = ObjectType(ObjectIdentity('CISCO-VLAN-MEMBERSHIP-MIB', 'vmVlan', vlan_id))
# Perform bulkwalk operation to retrieve the MAC address table
iterator = bulkCmd(
snmp_engine,
user,
target,
ContextData(),
oid,
lexicographicMode=False,
maxRepetitions=500,
acInfo=(vmVlan_oid, None)
)
But for some reason that throws the following error.
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'ObjectType'