node-js translate OIDs of snmp trap into textual object identifiers using the MIB description files

2.7k views Asked by At

I'm working on application that receive snmp trap and create a json object of this trap according to mib file in NodeJS. I've received the trap and print it using util.inspect according to this tutorial here: http://atlantageek.com/2014/08/23/snmp-trap-listener-in-node3/

and this is the code snippet:

trapd.on('trap', function(msg){
       result.push(msg);
   var now = new Date();
   console.log("Trap Received " + now);
   console.log(util.inspect(snmp.message.serializer(msg)['pdu'], false, null));
   console.log(result.length);
   });

How to translate OIDs of snmp trap into textual object identifiers using the MIB description files, is there any snmpjs built-in function or any other library such as [pysnmp in python] can I use it?!

Thanks in advance

2

There are 2 answers

1
Luay AL-Assadi On BEST ANSWER

Finally I' found this library, It's not optimal but it works fine after some editions.

https://github.com/PrimeEuler/mib.js

0
eephillip On

What about using the smi sub-component of pysnmp, called pysmi. It has a JSON compiler called JsonCodeGen. What about consuming that output.

http://pysmi.sourceforge.net/developer-documentation.html#pysmi.codegen.jsondoc.JsonCodeGen

https://github.com/etingof/pysmi/blob/master/examples/download-and-compile-smistar-mibs-into-json.py