Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

snmp-table-columns.js 951B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2013 Stephen Vickers
  2. var options = require("./option-parser");
  3. var session = options.session;
  4. var oid = options.oids[0];
  5. var columns = options.columns;
  6. var maxRepetitions = options.maxRepetitions || 20;
  7. function sortInt (a, b) {
  8. if (a > b)
  9. return 1;
  10. else if (b > a)
  11. return -1;
  12. else
  13. return 0;
  14. }
  15. function responseCb (error, table) {
  16. if (error) {
  17. console.error (error.toString ());
  18. } else {
  19. var indexes = [];
  20. for (var index in table)
  21. indexes.push (index);
  22. indexes.sort ();
  23. for (var i = 0; i < indexes.length; i++) {
  24. var columns = [];
  25. for (var column in table[indexes[i]])
  26. columns.push (parseInt (column));
  27. columns.sort (sortInt);
  28. console.log ("row for index = " + indexes[i]);
  29. for (var j = 0; j < columns.length; j++) {
  30. console.log (" column " + columns[j] + " = "
  31. + table[indexes[i]][columns[j]]);
  32. }
  33. }
  34. }
  35. }
  36. session.tableColumns (oid, columns, maxRepetitions, responseCb);