From: robert c. <rch...@ho...> - 2003-11-03 15:45:44
|
A list for users of pure-Python SNMP framework <pysnmp-users.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/pysnmp-users>, <mailto:pys...@li...?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum=pysnmp-users> I was trying to get the example snmptrap.py working using snmpv1. I found one bug and one "usability problem". The bug : in module rfc1157.py in \pysnmp-3.3.5\build\lib\pysnmp\proto\cli\ucd the following line is in error self.apiSetGenericTrap(int(args[2])) it should be self.apiGenSetGenericTrap(int(args[2])) The usability problem is that the module uses port 161 as a default. I believe Traps need to be sent to Port 162. Port 161 is the port for getting and setting SNMP values. Bob Chancer _________________________________________________________________ Concerned that messages may bounce because your Hotmail account has exceeded its 2MB storage limit? Get Hotmail Extra Storage! http://join.msn.com/?PAGE=features/es |
From: Romaneev V. <ent...@ya...> - 2011-09-20 12:00:37
|
I get incorrect string values, when try to receive MacAddress: FAQ says, that this problem solved in pysnmp-tools (such as pysnmpget), by using -OT flag. How can i realize this feature ? [root:ns:~/ordersw]#>python snmp.py | less 1.3.6.1.2.1.17.4.3.1.1.0.19.169.241.49.224 = '\x00\x13\xa9\xf11\xe0' 1.3.6.1.2.1.17.4.3.1.1.168.249.75.1.67.50 = '\xa8\xf9K\x01C2' 1.3.6.1.2.1.17.4.3.1.1.168.249.75.1.67.19 = '\xa8\xf9K\x01C\x13' and second question: when i try execute with string OID, not turple, a got an error like this: [root:ns:~/ordersw]#>python snmp.py Traceback (most recent call last): File "snmp.py", line 29, in <module> dot1dTpFdbTable <skipped> TypeError: can only concatenate tuple (not "str") to tuple But, documentation says: class ObjectIdentifier( objectIdentifier ) Create an ASN.1 Object Identifier object. The objectIdentifier parameter represents Object Identifier value. It should be either a tuple or tuple-like object or a string representing Object Identifier in dotted notation (like "1.3.6.1"). Instances of this class mimic basic properties of Python tuple. Sub-OIDs of an OID translate into tuple components. For more information on ObjectIdentifier class properties, refer to PyASN1 documentation. my source code: from pysnmp.entity.rfc3413.oneliner import cmdgen from pysnmp.proto import rfc1155, rfc1902, api from pyasn1.codec.ber import encoder, decoder hostname = '192.168.202.196' dot1dTpFdbTable = (1,3,6,1,2,1,17,4,3) cmdGen = cmdgen.CommandGenerator() cmdGen.ignoreNonIncreasingOid = True errorIndication, errorStatus, errorIndex, \ varBindTable = cmdGen.nextCmd( cmdgen.CommunityData('tlk-read', 'tlk-read'), cmdgen.UdpTransportTarget((hostname, 161)), dot1dTpFdbTable ) if errorIndication: print errorIndication else: if errorStatus: print '%s at %s\n' % ( errorStatus.prettyPrint(), errorIndex and varBindTable[-1][int(errorIndex)-1] or '?' ) else: for varBindTableRow in varBindTable: for name, val in varBindTableRow: print '%s = %s' % (name.prettyPrint(), val.prettyPrint()) |
From: Brian R. <py...@rh...> - 2011-09-20 13:35:34
|
Personally I have a function I use to do this. just hand it the object, and it returns the macs string in lowercase hex. import binascii def convertMac(octect): ''' This Function converts a binary mac address to a hexadecimal string representation ''' temp = list(octect) mac = [] for x in temp: mac.append(binascii.b2a_hex(x)) return ":".join(mac) --- Brian Raaen Network Architect br...@zc... On Tue, Sep 20, 2011 at 04:00:26PM +0400, Romaneev Vasya wrote: > I get incorrect string values, when try to receive MacAddress: > FAQ says, that this problem solved in pysnmp-tools (such as pysnmpget), by using -OT flag. > > How can i realize this feature ? > [root:ns:~/ordersw]#>python snmp.py | less > 1.3.6.1.2.1.17.4.3.1.1.0.19.169.241.49.224 = '\x00\x13\xa9\xf11\xe0' > 1.3.6.1.2.1.17.4.3.1.1.168.249.75.1.67.50 = '\xa8\xf9K\x01C2' > 1.3.6.1.2.1.17.4.3.1.1.168.249.75.1.67.19 = '\xa8\xf9K\x01C\x13' > > > and second question: > when i try execute with string OID, not turple, a got an error like this: > [root:ns:~/ordersw]#>python snmp.py > Traceback (most recent call last): > File "snmp.py", line 29, in <module> > dot1dTpFdbTable > <skipped> > > TypeError: can only concatenate tuple (not "str") to tuple > > > But, documentation says: > class ObjectIdentifier( objectIdentifier ) > Create an ASN.1 Object Identifier object. The objectIdentifier parameter represents Object Identifier value. It should be either a tuple or tuple-like object or a string representing Object Identifier in dotted notation (like "1.3.6.1"). > Instances of this class mimic basic properties of Python tuple. Sub-OIDs of an OID translate into tuple components. > For more information on ObjectIdentifier class properties, refer to PyASN1 documentation. > > my source code: > from pysnmp.entity.rfc3413.oneliner import cmdgen > from pysnmp.proto import rfc1155, rfc1902, api > from pyasn1.codec.ber import encoder, decoder > hostname = '192.168.202.196' > dot1dTpFdbTable = (1,3,6,1,2,1,17,4,3) > cmdGen = cmdgen.CommandGenerator() > cmdGen.ignoreNonIncreasingOid = True > errorIndication, errorStatus, errorIndex, \ > varBindTable = cmdGen.nextCmd( > cmdgen.CommunityData('tlk-read', 'tlk-read'), > cmdgen.UdpTransportTarget((hostname, 161)), > dot1dTpFdbTable > ) > if errorIndication: > print errorIndication > else: > if errorStatus: > print '%s at %s\n' % ( > errorStatus.prettyPrint(), > errorIndex and varBindTable[-1][int(errorIndex)-1] or '?' > ) > else: > for varBindTableRow in varBindTable: > for name, val in varBindTableRow: > print '%s = %s' % (name.prettyPrint(), val.prettyPrint()) > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > pysnmp-users mailing list > pys...@li... > https://lists.sourceforge.net/lists/listinfo/pysnmp-users |
From: Romaneev V. <ent...@ya...> - 2011-09-27 07:31:52
|
Hi, I'm using pysnmp-4.1.16c and full traceback is [root:ns:~/ordersw]#>python snmp.py Traceback (most recent call last): File "snmp.py", line 38, in <module> dot1dTpFdbTable File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 435, in nextCmd File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/entity/rfc3413/mibvar.py", line 31, in mibNameToOid File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 195, in getNodeNameByOid File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 177, in __getOidLabel TypeError: can only concatenate tuple (not "str") to tuple 20.09.2011, 23:55, "Ilya Etingof" <il...@gl...>: > [ skipped ] > >> and second question: >> when i try execute with string OID, not turple, a got an error like this: >> [root:ns:~/ordersw]#>python snmp.py >> Traceback (most recent call last): >> File "snmp.py", line 29, in <module> >> dot1dTpFdbTable >> <skipped> >> TypeError: can only concatenate tuple (not "str") to tuple > > Your code looks correct and I can't re-produce this issue on my system. > What pysnmp version do you use? > > Could you please send me the full traceback? > > -ilya ------ Романеев Василий aka BaZZiliO ICQ : 554370273 Мобильный в Самаре : +7-917-164-2-197 Мобильный в Ульяновске : +7-927-633-48-92 jabber v.r...@gm... skype romaneev |
From: Romaneev V. <ent...@ya...> - 2011-09-27 16:06:55
|
27.09.2011, 14:57, "Ilya Etingof" <il...@gl...>: > Please provide the code that causes this, especially line 38 at snmp.py i cut my code, so now it's follow: [root:ns:~/ordersw]#>cat code.py from pysnmp.entity.rfc3413.oneliner import cmdgen from pysnmp.proto import rfc1155, rfc1902, api from pyasn1.codec.ber import encoder, decoder hostname = '192.168.202.196' dot1dTpFdbTableStr = "1.3.6.1.2.1.17.4.3" cmdGen = cmdgen.CommandGenerator() cmdGen.ignoreNonIncreasingOid = True errorIndication, errorStatus, errorIndex, \ varBindTable = cmdGen.nextCmd( cmdgen.CommunityData('tlk-read', 'tlk-read'), cmdgen.UdpTransportTarget((hostname, 161)), dot1dTpFdbTableStr ) Line 19 is "errorIndication, errorStatus, errorIndex, \ varBindTable = cmdGen.nextCmd( cmdgen.CommunityData('tlk-read', 'tlk-read'), cmdgen.UdpTransportTarget((hostname, 161)), dot1dTpFdbTableStr )" there is an error: [root:ns:~/ordersw]#>python code.py Traceback (most recent call last): File "code.py", line 19, in <module> dot1dTpFdbTableStr File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 435, in nextCmd File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/entity/rfc3413/mibvar.py", line 31, in mibNameToOid File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 195, in getNodeNameByOid File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 175, in __getOidLabel File "build/bdist.freebsd-8.1-RELEASE-i386/egg/pysnmp/smi/view.py", line 177, in __getOidLabel TypeError: can only concatenate tuple (not "str") to tuple ------ Романеев Василий aka BaZZiliO ICQ : 554370273 Мобильный в Самаре : +7-917-164-2-197 Мобильный в Ульяновске : +7-927-633-48-92 jabber v.r...@gm... skype romaneev |
From: Romaneev V. <ent...@ya...> - 2011-09-27 18:48:46
|
I've found working solution for me,thanks! But if it would helpful, i can help in debugging - what's wrong If my solution is correct - examples should be update dot1dTpFdbTableStr = "1.3.6.1.2.1.17.4.3" errorIndication, errorStatus, errorIndex, \ varBindTable = cmdGen.nextCmd( cmdgen.CommunityData(community, community), cmdgen.UdpTransportTarget((hostname, 161)), rfc1902.ObjectName(dot1dTpFdbTableStr) ) 27.09.2011, 20:06, "Romaneev Vasya" <ent...@ya...>: > 27.09.2011, 14:57, "Ilya Etingof" <il...@gl...>: > >> Please provide the code that causes this, especially line 38 at snmp.py |
From: Romaneev V. <ent...@ya...> - 2011-09-29 05:35:18
|
http://pysnmp.sourceforge.net/docs/4.x/index.html#OID-IMPL Create an ASN.1 Object Identifier object. The objectIdentifier parameter represents Object Identifier value. It should be either a tuple or tuple-like object or a string representing Object Identifier in dotted notation (like "1.3.6.1"). 28.09.2011, 19:24, "Ilya Etingof" <il...@gl...>: > Existing API supports OIDs in the following forms: > > * tuple form - (1,3,6,1,2,1,17,4,3) > * MIB name form - (('SNMPv2-MIB', 'sysName'), 0) > * ObjectIdentifier form -- rfc1902.ObjectName("1.3.6.1.2.1.17.4.3") > > What you have initially used (plain string form "1.3.6.1.2.1.17.4.3") is > not supported. Have you seen it in the examples? Please let me know where. > > -ilya |
From: Johan G. <joh...@gm...> - 2015-05-21 02:26:47
|
Hi all, I would appreciate some help with the getcmd in the following code. I get a serialization error. Eventually i will have multiple targets and would like to keep that in a loop. The OID will also be a custom OID without loading the MIB. Thank you J from pysnmp.entity.rfc3413.oneliner import cmdgen def cbFun(sendRequestHandle, errorIndication, \ errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return if errorStatus: print('%s at %s' % \ (errorStatus.prettyPrint(), errorIndex and varBindTable[-1][int(errorIndex)-1] or '?') ) return for varBindRow in varBindTable: for oid, val in varBindRow: if val is None: return # stop table retrieval else: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) return True # continue table retrieval cmdGen = cmdgen.AsynCommandGenerator() for transportTarget in ( cmdgen.UdpTransportTarget(('192.168.10.107', 161)), ): cmdGen.getCmd( cmdgen.UsmUserData('user', 'authpassword', 'privpassword', authProtocol=cmdgen.usmHMACSHAAuthProtocol, privProtocol=cmdgen.usmAesCfb128Protocol), transportTarget, ('1.3.6.1.2.1.1.5.0'), (cbFun, None), lookupNames=False, lookupValues=False ) cmdGen.snmpEngine.transportDispatcher.runDispatcher() |
From: Ilya E. <il...@gl...> - 2015-05-21 06:39:29
|
Hi Johan, You are supposed to pass a sequence of OIDs, not just one: > cmdGen.getCmd( > cmdgen.UsmUserData('user', 'authpassword', 'privpassword', > authProtocol=cmdgen.usmHMACSHAAuthProtocol, > privProtocol=cmdgen.usmAesCfb128Protocol), > transportTarget, > ( ('1.3.6.1.2.1.1.5.0’), ), > (cbFun, None), > ) -ilya > On 21 May 2015, at 05:26, Johan Geldenhuys <joh...@gm...> wrote: > > Hi all, > > I would appreciate some help with the getcmd in the following code. I get a serialization error. > Eventually i will have multiple targets and would like to keep that in a loop. The OID will also be a custom OID without loading the MIB. > > Thank you > J > > > > > from pysnmp.entity.rfc3413.oneliner import cmdgen > > def cbFun(sendRequestHandle, errorIndication, \ > errorStatus, errorIndex, varBindTable, cbCtx): > if errorIndication: > print(errorIndication) > return > if errorStatus: > print('%s at %s' % \ > (errorStatus.prettyPrint(), > errorIndex and varBindTable[-1][int(errorIndex)-1] or '?') > ) > return > > for varBindRow in varBindTable: > for oid, val in varBindRow: > if val is None: > return # stop table retrieval > else: > print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) > > return True # continue table retrieval > > cmdGen = cmdgen.AsynCommandGenerator() > > for transportTarget in ( cmdgen.UdpTransportTarget(('192.168.10.107', 161)), > ): > > cmdGen.getCmd( > cmdgen.UsmUserData('user', 'authpassword', 'privpassword', > authProtocol=cmdgen.usmHMACSHAAuthProtocol, > privProtocol=cmdgen.usmAesCfb128Protocol), > transportTarget, > ('1.3.6.1.2.1.1.5.0'), > (cbFun, None), > lookupNames=False, lookupValues=False > ) > > cmdGen.snmpEngine.transportDispatcher.runDispatcher() > |
From: Ilya E. <il...@gl...> - 2003-11-03 15:58:01
|
A list for users of pure-Python SNMP framework <pysnmp-users.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/pysnmp-users>, <mailto:pys...@li...?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum=pysnmp-users> > The bug : in module rfc1157.py in > \pysnmp-3.3.5\build\lib\pysnmp\proto\cli\ucd > the following line is in error [ skipped ] That's fixed in 3.3.6 release. Please, upgrade. > The usability problem is that the module uses port 161 as a default. I > believe Traps need to be sent to Port 162. Port 161 is the port for getting > and setting SNMP values. That's right. Fixed at CVS. Will take effect in 3.3.7. -ilya |