etingof / pysmi

SNMP MIB parser
http://snmplabs.com/pysmi/
BSD 2-Clause "Simplified" License
137 stars 52 forks source link

Nodejs and typescript #53

Open yboujraf opened 4 years ago

yboujraf commented 4 years ago

Dear

any chance to have your mib parser in nodejs and typescript or javascript?

Best Regards Youssef

etingof commented 4 years ago

Do you mean MIBs transformed into JSON objects (which is already done) or the entire code base rewritten in some other language (which is unlikely)?

yboujraf commented 4 years ago

Dear @etingof

Thanks for your quick answer.

Topic 1 : Node.js & typescript or javascript

Yes I am looking for a Mib parser where all dependencies are included in a folder and with the parser to check if no dependency is missing , if not , need to be transformed into json object into a file in Node.js and typescript or javascript ?

I read your documentation and it 's exactly what I am looking for but can't use because only supporting node.js and typescript.

This tools for us is more to look for parameters to control a device are available. You know most of the time the sale guy sell more than the device can do or could do ;-)

This is the example I have found in github but for example when it is a sequence, it is not clear and missing the all definition of the asn structure :

mib.zip

Sample where some index in a parameter are incorrect or could not be parsed

Could you try if you could parse and create the json file ?

TT1260-MIBS.zip RX1290_MIBs.zip

Thanks in advance if you could help me or share some links ?

Best Regards, Youssef

etingof commented 4 years ago

I am still confused, I am not sure I understand what you need.

If you have MIB in JSON form, can't it be readily consumed by JS code?

PySMI parser will fail on unresolved dependencies between MIB modules. So JSONs it produces are always valid in that regard.

If you are looking for some other structure of JSON document, PySMI is entirely driven by Jinja2 templates - you can create your own and render some other JSON.

yboujraf commented 4 years ago

Dear @etingof

Sorry to confusing you.

I have only Mib files with dependencies sometime missing and need to google to download it.

Now I need to parse the Mib files with the dependencies and to transform them into json object and look like we have a mib browser.

the picture is just to showing the structure expected but we don't want to create a mib browser.

image

We have a gateway that needs to exchange data between snmp and proprietary protocol.

Then If I could parse the mibs , generate with success the json object file, I am saved ;-)

Again Best regards Youssef

etingof commented 4 years ago

PySMI's mibdump tool can generate a JSON like this from any given MIB. The tool will attempt to download dependencies from mibs.snmplabs.com. If the dependency is missing, the whole compilation will fail.

If JSON structure referenced above does not suit your needs, you can probably reshape it with common JSON manipulation tools.

lextm commented 2 years ago

Writing a MIB parser is nothing new than applying lex & yacc to the ASN.1 and SMI based grammar. So, if this project can do it for Python, you can also do the same for JavaScript/TypeScript.

Writing parsers/compilers is not a trivial topic even for computer science students. Therefore, rarely you see an open source one if clearly there is value in it.