Implementing a custom MIB in a PySNMP agent

五迷三道 提交于 2019-12-03 09:09:33

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.

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!