How to implement custom MIB in PySNMP?

I already have a MIB text file (do I need to somehow do this in a .py file?). I am trying to use PySNMP (not net-snmp). I was able to connect to my device and print some information, but the information was not very useful (just ObjectName, ObjectIdentifier, etc.). I want to be able to communicate with the device (send commands to change and read values), but all the tutorials that I saw seem to help a little. Does anyone know how I can use my own MIB to communicate effectively with my device? Any good sites that I miss? http://pysnmp.sourceforge.net/ is fine, but I need something else ...

+6
source share
1 answer

To use MIB with pysnmp, you must first convert the MIB to pysnmp format (which is a collection of Python objects). The conversion is performed using the pysnmp / tools / build-pysnmp-mib shell script as follows:

$ sh build-pysnmp-mib -h build-pysnmp-mib: illegal option -- h Convert MIB text file into PySNMP-compliant module, see http://pysnmp.sf.net. Usage: build-pysnmp-mib [-o pysnmp-mib-file ] [ mib-text-file ] 

Make sure you have libsmi installed (pysnmp scripts use the smidump tool from the libsmi distribution).

If you don't put your new Mys file in pysnmp in pysnmp / smi / mibs / (which isn’t very good), you will also need to point pysnmp to the place where your own MIBs are located. This can be done as described here .

Once you are done with the MIB, you can use it from your scripts, as described here .

You can quickly check how your new MIB works by calling the pysnmpget / pysnmpset tools that come with the pysnmp-apps package.

By the way, most likely, the MIB you need to work with is already converted to the pysnmp format and distributed with the pysnmp-mibs package.

+8
source

Source: https://habr.com/ru/post/917404/


All Articles