Node-Red configuration
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

snmp-get-bulk.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2013 Stephen Vickers
  2. var snmp = require ("../");
  3. var options = require("./option-parser");
  4. var session = options.session;
  5. var oids = options.oids;
  6. var nonRepeaters = options.nonRepeaters || 0;
  7. var maxRepetitions = options.maxRepetitions || 20;
  8. session.getBulk (oids, nonRepeaters, maxRepetitions, function (error,
  9. varbinds) {
  10. if (error) {
  11. console.error (error.toString ());
  12. } else {
  13. // step through the non-repeaters which are single varbinds
  14. for (var i = 0; i < nonRepeaters; i++) {
  15. if (i >= varbinds.length)
  16. break;
  17. if (snmp.isVarbindError (varbinds[i]))
  18. console.error (snmp.varbindError (varbinds[i]));
  19. else
  20. console.log (varbinds[i].oid + "|" + varbinds[i].value);
  21. }
  22. // then step through the repeaters which are varbind arrays
  23. for (var j = nonRepeaters; j < varbinds.length; j++) {
  24. for (var k = 0; k < varbinds[j].length; k++) {
  25. if (snmp.isVarbindError (varbinds[j][k]))
  26. console.error (snmp.varbindError (varbinds[j][k]));
  27. else
  28. console.log (varbinds[j][k].oid + "|" + varbinds[j][k].value);
  29. }
  30. }
  31. }
  32. });