1

I have installed pysnmp-4.x.I am getting following error during running a SNMP program.

I am using pysnmpSE 3.5.2 now but getting same error. I found that pysnmpSE doesn't hav v4 module. I was suggested that following error should resolved if pySNMP SE 3.x is used.

Traceback (most recent call last):
  File "C:\Documents and Settings\ggne0622\Desktop\Python\google-python-exercises\babynames\SimpleAgent.py", line 18, in <module>
    from twistedsnmp import agent, agentprotocol, bisectoidstore
  File "C:\Python27\Lib\site-packages\twistedsnmp\agent.py", line 4, in <module>
    from twistedsnmp import datatypes
  File "C:\Python27\Lib\site-packages\twistedsnmp\datatypes.py", line 7, in <module>
    from twistedsnmp.pysnmpproto import v2c,v1
  File "C:\Python27\Lib\site-packages\twistedsnmp\pysnmpproto.py", line 13, in <module>
    from pysnmp.v4.proto.omni import v2c,v1, error, rfc1157, rfc1905
ImportError: No module named v4.proto.omni

Code:

#!/usr/bin/env python
from twisted.internet.iocpreactor import reactor
from twisted.internet import error as twisted_error
from twistedsnmp import agent, agentprotocol, bisectoidstore
#from twisted.internet import interfaces
try:
from twistedsnmp import bsdoidstore
except ImportError:
import warnings
warnings.warn( """No BSDDB OID Storage available for testing""" )
bsdoidstore = None

def createAgent( oids ):
ports = [161]+range(20000,25000)
for port in ports:
try:

        `agentObject = reactor.IOCPReactor.listenUDP(port,`   `agentprotocol.AgentProtocol(snmpVersion = 'v2c',agent = agent.Agent(dataStore =`   `bisectoidstore.BisectOIDStore(OIDs = oids,),),),)`  
    `except twisted_error.CannotListenError:`  
        `pass`  
    `else:`  
        `return agentObject, port`  

testingOIDs = {
'.1.3.6.1.2.1.1.1.0': 'Some tool out in the field',
'.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1',
'.1.3.6.1.2.1.1.3.0': 558566090,
'.1.3.6.1.2.1.1.4.0': "support@somewhere.ca",
'.1.3.6.1.2.1.1.5.0': "NameOfSystem",
'.1.3.6.1.2.1.1.6.0': "SomeHeadEnd, West Hinterlands, Canada",
}

def main(oids=testingOIDs):
agent, port = createAgent( oids )

if __name__ == "__main__":
reactor.IOCPReactor.callWhenRunning( main )
reactor.IOCPReactor.run()

4

1 回答 1

0

TwistedSNMP 似乎不适合与 PySNMP 4.x 一起使用。因此,您应该使用 PySNMP 3.x / PySNMP SE 或切换到具有自己的 Twisted 绑定的 PySNMP 4.x。

于 2013-04-23T11:58:29.423 回答