Implementing a custom MIB in a PySNMP agent

前端 未结 2 1553
没有蜡笔的小新
没有蜡笔的小新 2021-02-11 10:01

I\'m having difficulty implementing a custom MIB in a PySNMP agent.

I\'ve started with:

http://pysnmp.sourceforge.net/examples/4.x/v3arch/agent/cmdrsp.html

相关标签:
2条回答
  • 2021-02-11 10:30

    As for implementing a Managed Object Instance, you have two choices:

    1. Load and subclass the MibScalarInstance class, then override its readGet() method to make it returning your live value. Then instantiate your new class (make sure to pass it appropriate OID that identifies it) and pass it to exportSymbols(), so its OID will get registered at pysnmp Agent.

    2. Load the Integer32 class, subclass it and override its "clone()" method to make it returning your live value. Then load the MibScalarInstance class, instantiate it passing appropriate OID and the instance of your Integer32 subclass, then pass MibScalarInstance object to exportSymbols(), so its OID will get registered at pysnmp Agent.

    It may make sense to keep all your code in your own MIB module. Take a look at pysnmp/smi/mibs/instances/*.py to get an idea.

    From within your Agent app, invoke mibBuilder.loadModules('TRC-MIB') to load your MIB module into Agent.

    In your code you seem to somehow combine the above two approaches: MyDeliveryTime.readGet() will not work, however MyDeliveryTime.clone() or deliveryTimeInstance.readGet() will.

    0 讨论(0)
  • 2021-02-11 10:30

    I also faced a similar issue:

    Tried putting the MY-MIB.[pyc] files in the ~/.pysnmp/mibs folders but I think what really worked was putting these files in the folder /usr/lib/pytho*/site/pysnmp/smi/mibs/ .

    Am working on pysnmp-4.3.9

    0 讨论(0)
提交回复
热议问题