dmaster
dmaster

Reputation: 99

Pysnmp Command responder wrapper

I want to develop simple pysnmp command responder to listen to my test instrument device, get requests came from the device and replace them with my own command (Telnet command)in my host PC (Ubuntu) and send it to evaluation board. In the past there was also support SNMP on HOST, I want to just keep the structure of exists PLUGIN on device and change only the Host side.

Please do not ask me why I do it that way. I have prepared MIB file that works with the device in SNMP. PLUGIN installed on device knows how to work and send the MIB OID with the OID I know and according to the request need to replace by command of my own command on host PC. Please see the flow for example get frequency from evaluation board:

Plugin in device send command to get frequency (MIB OID): 1.3.6.1.4.1.55555.1.1.5.1.1.2.1

Listen to Device (SNMPv1 port 161), get request(1.3.6.1.4.1.55555.1.1.5.1.1.2.1) for frequency from device and replace it in local PC Host(Ubuntu): get_frequency_mycommand_telnet

How to do it in the most simple with Python 2.7?

Upvotes: 0

Views: 312

Answers (1)

Ilya Etingof
Ilya Etingof

Reputation: 5555

Let me suggest you basing your script on this example.

You could implement your telnet communication inside the __call__() of your custom MIB object instance. Make sure to set proper OID to make this object SNMP-addressable.

Also, add support for SNMP SET operation and probably pass incoming value into the __call__() or other method you may want to implement.

You may want to scratch IPv6 support if you do not need it.

Keep in mind that with this implementation __call__() is blocking so no other SNMP queries would be processed until __call__() is done. You could enhance it towards higher performance and concurrency by making your telnet client asynchronous.

Upvotes: 1

Related Questions