Re: [pysnmp-users] bulkcmd works in old example code, but not in new example.
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2017-09-27 05:52:19
|
Hi Gee, I think with both old and new code you should pass OID in either of the two forms: - as a string (1.3.6.1.1…) or - tuple of integers (1, 3, 6, 1, …) e,g,: ObjectType(ObjectIdentity((1, 3, 6, 1, 2, 1, 17, 4, 3, 1, 1))), Note extra parentheses around the numbers. > On 25 Sep 2017, at 19:02, Gee Zany <tuv...@ou...> wrote: > > Old example code: http://pysnmp.sourceforge.net/examples/current/v3arch/oneliner/manager/cmdgen/getbulk-v2c.html > > New example code: http://pysnmp.sourceforge.net/examples/hlapi/asyncore/sync/manager/cmdgen/table-operations.html#fetch-scalar-and-table-variables > > My code based on old example: > https://pastebin.com/FFrf9qjP > > My code based on new example: > https://pastebin.com/Jhu4J3CV > > I am trying to extract a particular OID (1.3.6.1.2.1.17.4.3.1.1) from a Cisco switch via the bulkcmd function. However, I took reference from your old example and it works. However, when I referenced from your new example, it throws errors as follows: > > Traceback (most recent call last): > File "C:\Users\user3\PycharmProjects\SNMPCisco1\tst2.py", line 32, in <module> > ObjectType(ObjectIdentity(1, 3, 6, 1, 2, 1, 17, 4, 3, 1, 1)), > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\hlapi\asyncore\sync\cmdgen.py", line 538, in bulkCmd > initialVars = [x[0] for x in vbProcessor.makeVarBinds(snmpEngine, varBinds)] > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\hlapi\varbinds.py", line 39, in makeVarBinds > __varBinds.append(varBind.resolveWithMib(mibViewController)) > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\smi\rfc1902.py", line 845, in resolveWithMib > self.__args[0].resolveWithMib(mibViewController) > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\smi\rfc1902.py", line 481, in resolveWithMib > self.__modName, self.__symName > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\smi\builder.py", line 400, in importSymbols > self.loadModules(modName, **userCtx) > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\smi\builder.py", line 362, in loadModules > self.loadModule(modName, **userCtx) > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\smi\builder.py", line 306, in loadModule > modData, sfx = mibSource.read(modName) > File "C:\Users\user3\AppData\Local\Programs\Python\Python36\lib\site-packages\pysnmp\smi\builder.py", line 79, in read > pycData = self._getData(f + pycSfx, pycMode) > TypeError: unsupported operand type(s) for +: 'int' and 'str' > > I tried removing the for loop in the new example code, but the same error occurred. > > Any guidance is deeply appreciated. Cheers. |