Need to create custom OID on my computer that will respond to get and set commands

Viewed 45

I have a generic SNMP agent emulator, but I don't know if it works with my computers existing MIBS and OIDs or simply responds to the Master's get/set commands in a vacuum. I need to be able to ensure that the agent emulator responds to a get command for a specific OID that does not reside in any of my computers MIBS.

This is my agent:

config.addVacmUser(snmpEngine, 3, 'my-area', 'noAuthNoPriv', (1,3,6), (1,3,6))
snmpContext = context.SnmpContext(snmpEngine)

class FileInstrumController(instrum.AbstractMibInstrumController):
    def readVars(self, vars, acInfo=(None, None)):
        try:
            return [ (o,v2c.OctetString(open('/tmp/%s.txt' % o, 'r').read())) for o,v in vars ]
        except IOError:
            raise error.SmiError

    def writeVars(self, vars, acInfo=(None, None)):
        try:
            for o,v in vars:
                open('/tmp/%s.txt' % o, 'w').write(str(v))
            return vars
        except IOError:
            raise error.SmiError

snmpContext.registerContextName(
    v2c.OctetString('my-context'),          # Context Name
    FileInstrumController()                 # Management Instrumentation
)
cmdrsp.GetCommandResponder(snmpEngine, snmpContext)
cmdrsp.SetCommandResponder(snmpEngine, snmpContext)

snmpEngine.transportDispatcher.jobStarted(1)
try:
    snmpEngine.transportDispatcher.runDispatcher()
except:
    snmpEngine.transportDispatcher.closeDispatcher()
    raise

I am looking into the UUID object capabilities to generate a specific and unique OID, but don't know if this is the right path to take.

0 Answers
Related