The other day, a modem broke down, and I acquired a new TP-LINK TD8816 to replace it. I've been trying to get my feet wet in SNMP to get at the modem stats. Here are the steps I took:
- I enabled SNMP in the modem, on the LAN port only.
- I installed pysnmp (4.2.5) and pysnmp-mibs
- Installed and compiled mbrowse
- Set the snmp.conf to a minimal
rocommunity public default .1.3.6.1.2.1.1
When I try to access variables in the adslMIB, none are found:
Using mbrowse I see many declared variables, but 'get' tells me the variable doesn't exit. The (modified) pysnmp 'one-liner' demo program produces an error (see below).
I can access sysDescr and OID in the modem:
$ snmpwalk -Os -c public -v 1 10.0.0.2 1.3.6.1.2.1.1.1
sysDescr.0 = STRING: TD-8816
$ snmpwalk -Os -c public -v 1 10.0.0.2 1.3.6.1.2.1.1.2
sysObjectID.0 = OID: enterprises.1.2.3.4.5
but nothing else...
This is the modified pysnmb script:
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp import debug
class SNMP_access():
def __init__(self):
self.cmdGen = cmdgen.CommandGenerator()
def test(self):
errorIndication, errorStatus, errorIndex, varBinds = \
self.cmdGen.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('10.0.0.2', 161)),
cmdgen.MibVariable('ADSL-LINE-MIB', 'adslAturPerfLoss', '0')
)
# Check for errors and print out results
if errorIndication:
print(errorIndication)
else:
if errorStatus:
print('%s at %s' % (
errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex)-1] or '?'
)
)
else:
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
def main():
# use specific flags or 'all' for full debugging
#debug.setLogger(debug.Debug('dsp', 'msgproc', 'secmode'))
snmp = SNMP_access()
snmp.test()
return 0
if __name__ == '__main__':
main()
and the resulting traceback:
Traceback (most recent call last):
File "snmptest.py", line 63, in <module>
main()
File "snmptest.py", line 59, in main
snmp.test()
File "snmptest.py", line 37, in test
cmdgen.MibVariable('ADSL-LINE-MIB', 'adslAturPerfLoss', '0')
File "/usr/lib64/python2.7/site-packages/pysnmp-4.2.5-py2.7.egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 424, in getCmd
kwargs.get('contextName', null)
File "/usr/lib64/python2.7/site-packages/pysnmp-4.2.5-py2.7.egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 277, in getCmd
self.makeReadVarBinds(varNames),
File "/usr/lib64/python2.7/site-packages/pysnmp-4.2.5-py2.7.egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 201, in makeReadVarBinds
[ (x, self._null) for x in varNames ], oidOnly=True
File "/usr/lib64/python2.7/site-packages/pysnmp-4.2.5-py2.7.egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 209, in makeVarBinds
varName.resolveWithMib(self.mibViewController, oidOnly=True)
File "/usr/lib64/python2.7/site-packages/pysnmp-4.2.5-py2.7.egg/pysnmp/entity/rfc3413/oneliner/mibvar.py", line 180, in resolveWithMib
instIds = rowNode.getInstIdFromIndices(*self.__args[2:])
File "/usr/lib64/python2.7/site-packages/pysnmp-4.2.5-py2.7.egg/pysnmp/smi/mibs/SNMPv2-SMI.py", line 1096, in getInstIdFromIndices
mibObj.syntax.clone(indices[idx]), impliedFlag
File "/usr/lib64/python2.7/site-packages/pyasn1-0.1.7-py2.7.egg/pyasn1/type/univ.py", line 107, in clone
return self.__class__(value, tagSet, subtypeSpec, namedValues)
File "/usr/lib64/python2.7/site-packages/pyasn1-0.1.7-py2.7.egg/pyasn1/type/univ.py", line 22, in __init__
self, value, tagSet, subtypeSpec
File "/usr/lib64/python2.7/site-packages/pyasn1-0.1.7-py2.7.egg/pyasn1/type/base.py", line 69, in __init__
self._verifySubtypeSpec(value)
File "/usr/lib64/python2.7/site-packages/pyasn1-0.1.7-py2.7.egg/pyasn1/type/base.py", line 33, in _verifySubtypeSpec
raise c('%s at %s' % (i, self.__class__.__name__))
pyasn1.type.error.ValueConstraintError: ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(-2147483648, 2147483647)), ValueRangeConstraint(1, 2147483647)) failed at: "ValueRangeConstraint(1, 2147483647) failed at: "0"" at InterfaceIndex
EDIT: Some more details, in response to Ilya's reply:
- The vendor does not publish MIBs. On their forums I found several 'guesses'
- There are no options in the modem config to limit access.
- I ran snmpwalk with -v1 and -v2c, and the output was the same
- I went over the communities with a telnet connection, and only the 'get' community name is public (no other ro communities found)
- No other SNMP-enabled interfaces here.
- The modem is actually connected. I can interrogate all parameters (adsl and others) via the telnet interface, even detailed data about SNR in each of the channel frequencies.