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

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);