Пример #1
0
    def __init__(self, host, port, community):
        self.snmp = engine.SnmpEngine()
        self.snmp.registerTransportDispatcher(dispatch.TwistedDispatcher())

        config.addV1System(self.snmp, 'my-area', community)
        config.addTargetParams(self.snmp, 'my-creds', 'my-area',
                               'noAuthNoPriv', 0)
        config.addSocketTransport(self.snmp, udp.domainName,
                                  udp.UdpTwistedTransport().openClientMode())
        config.addTargetAddr(self.snmp, 'my-router', udp.domainName,
                             (host, port), 'my-creds')
Пример #2
0
    def __init__(self):
        self.unReadyNodes = list()
        self.identifiers = dict()
        self.snmpEngine = engine.SnmpEngine()
        self.bcmdgen = cmdgen.BulkCommandGenerator()

        self.snmpEngine.registerTransportDispatcher(
            dispatch.TwistedDispatcher())
        config.addV1System(self.snmpEngine, 'test-agent', SNMP_COMMUNITY)
        config.addTargetParams(self.snmpEngine, 'myParams', 'test-agent',
                               'noAuthNoPriv', 1)

        config.addSocketTransport(self.snmpEngine, udp.domainName,
                                  udp.UdpTwistedTransport().openClientMode())

        self.carbonFact = CarbonFactory(self)
        reactor.connectTCP(GRAPHITE_HOST, 2003, self.carbonFact)
Пример #3
0
from twisted.internet import reactor, defer
from pysnmp.entity import engine, config
from pysnmp.carrier.twisted import dispatch
from pysnmp.carrier.twisted.dgram import udp
from pysnmp.entity.rfc3413.twisted import cmdgen
from pysnmp.proto import rfc1902
#from pysnmp import debug

## Optional debugging ('all' enables full debugging)
#debug.setLogger(debug.Debug('io', 'dsp', 'msgproc', 'secmod', 'app'))

# Create SNMP engine instance
snmpEngine = engine.SnmpEngine()

# Set Twisted dispatcher
snmpEngine.registerTransportDispatcher(dispatch.TwistedDispatcher())

#
# SNMPv1/2c setup (if you use SNMPv1 or v2c)
#

## SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')

## Specify security settings per SecurityName (SNMPv1 - 0, SNMPv2c - 1)
#config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 0)
config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1)

#
# SNMPv3/USM setup (choose any one if you use SNMPv3/USM)
#