Node-Red configuration
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

test.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* eslint-disable no-unused-vars */
  2. var snmp = require ("../");
  3. var getopts = require ("getopts");
  4. var options = getopts(process.argv.slice(2));
  5. var providers;
  6. var mibDir = '/var/tmp/mibs/';
  7. var counter64 = function (num) {
  8. var buf = Buffer.alloc (4);
  9. buf.writeUInt32BE (num);
  10. return buf;
  11. };
  12. var snmpOptions = {
  13. disableAuthorization: options.n,
  14. port: options.p,
  15. engineID: options.e,
  16. debug: options.d
  17. };
  18. var callback = function (error, data) {
  19. if ( error ) {
  20. console.error (error);
  21. } else {
  22. console.log (data.pdu.varbinds[0].oid);
  23. }
  24. };
  25. var store = snmp.createModuleStore ();
  26. var agent = snmp.createAgent (snmpOptions, callback);
  27. var mib = agent.getMib ();
  28. var authorizer = agent.getAuthorizer ();
  29. authorizer.addCommunity ("public");
  30. // IF-MIB load and providers registration
  31. store.loadFromFile (mibDir + "IPv6-TC.mib");
  32. store.loadFromFile (mibDir + "IPv6-MIB.mib");
  33. providers = store.getProvidersForModule ("IPV6-MIB");
  34. mib.registerProviders (providers);
  35. // agent.getMib ().dumpProviders ();
  36. // mib.dump ();
  37. var modules = store.getModules (true);
  38. var one = store.getModule ("IPV6-MIB");
  39. var names = store.getModuleNames (true);
  40. // console.log("All modules: ", JSON.stringify(modules, '', 2));
  41. console.log("Modules: ", names);
  42. console.log("Single module definition: ", JSON.stringify(one, '', 2));