markabrahams / node-net-snmp

JavaScript implementation of the Simple Network Management Protocol (SNMP)
207 stars 97 forks source link

Is it possible to omit the OID argument in walk method to make the function behave like snmpwalk command #191

Closed devqazi closed 2 years ago

devqazi commented 2 years ago

If we use snampwalk from command line without any oid, it fetches all of the oids. I similar not supported in the session.walk method. I tried omitting the first parameter in the method but apparently it didnt work.

const session = snmp.createSession('127.0.0.1', 'public');

// I tried it like this

session.walk ('', maxRepetitions, feedCb, doneCb);

// and this
session.walk (undefined, maxRepetitions, feedCb, doneCb);
markabrahams commented 2 years ago

Hi @devqazi - no, the library's session.walk command doesn't support fetching all OIDs for a null or empty-string OID. Even though the library call is not designed to directly mimic the Net-SNMP functionality, it would be possible to change the library to align with the Net-SNMP command-line snmpwalk behaviour for this case.

However, on thinking about this further, I'm of the opinion to leave the current behaviour as is. The reason being that it is fairly easy to forget to define a variable, and in that case I would rather throw an error than have the calling code mistakenly walk the entire MIB of a device. So I think the current behaviour is safer, and therefore will keep it unchanged.

If you do want to walk the entire MIB, simply call: session.walk ('1.3.6.1', maxRepetitions, feedCb, doneCb)

devqazi commented 2 years ago

I cant thank you enough. Thats exactly what I needed. I thought the library ddint support walking the whole MIB at all

markabrahams commented 2 years ago

No problems @devqazi !