1

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.

Digit_Fish
  • 21
  • 2
  • Update: I changed my OID to hex form in hopes to use with UUIDs in case this is a viable option:`OID = '1.3.6.1.4.1.30397.4.1.2.1.0' print('Target OID to Emulate: ' + OID) c = uuid.uuid1() print ('UUID format:') print(c.bytes) OID_LIST = OID.split(".") print ('OID as list: ') print(OID_LIST) OID_HEX1 = "" for x in OID_LIST: interger = int(x) y = hex(interger) OID_HEX1 += (y + ".") OID_HEX2 = OID_HEX1.replace('0x','x') ##<---- turns 0x1.0x3.... into x1.x3..... print ("OID in hexadecimal is: " + OID_HEX2)` – Digit_Fish Jun 13 '22 at 19:36

0 Answers0