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-proxy.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var snmp = require ("../");
  2. var getopts = require ("getopts");
  3. var options = getopts(process.argv.slice(2));
  4. var snmpOptions = {
  5. disableAuthorization: options.n,
  6. port: options.p,
  7. engineID: options.e,
  8. debug: options.d
  9. };
  10. var callback = function (error, data) {
  11. if ( error ) {
  12. console.error (error);
  13. } else {
  14. console.log (JSON.stringify(data.pdu.varbinds, null, 2));
  15. }
  16. };
  17. var agent = snmp.createAgent(snmpOptions, callback);
  18. var authorizer = agent.getAuthorizer ();
  19. authorizer.addCommunity ("public");
  20. authorizer.addUser ({
  21. name: "fred",
  22. level: snmp.SecurityLevel.noAuthNoPriv
  23. });
  24. authorizer.addUser ({
  25. name: "betty",
  26. level: snmp.SecurityLevel.authNoPriv,
  27. authProtocol: snmp.AuthProtocols.sha,
  28. authKey: "illhavesomeauth"
  29. });
  30. authorizer.addUser ({
  31. name: "wilma",
  32. level: snmp.SecurityLevel.authPriv,
  33. authProtocol: snmp.AuthProtocols.sha,
  34. authKey: "illhavesomeauth",
  35. privProtocol: snmp.PrivProtocols.des,
  36. privKey: "andsomepriv"
  37. });
  38. var forwarder = agent.getForwarder ();
  39. forwarder.addProxy({
  40. context: "freds",
  41. transport: "udp4",
  42. target: "localhost",
  43. port: 2161,
  44. user: {
  45. name: "fred",
  46. level: snmp.SecurityLevel.noAuthNoPriv
  47. }
  48. });
  49. forwarder.addProxy({
  50. context: "bettys",
  51. transport: "udp4",
  52. target: "localhost",
  53. port: 2161,
  54. user: {
  55. name: "betty",
  56. level: snmp.SecurityLevel.authNoPriv,
  57. authProtocol: snmp.AuthProtocols.sha,
  58. authKey: "illhavesomeauth"
  59. }
  60. });
  61. forwarder.addProxy({
  62. context: "wilmas",
  63. transport: "udp4",
  64. target: "localhost",
  65. port: 2161,
  66. user: {
  67. name: "wilma",
  68. level: snmp.SecurityLevel.authPriv,
  69. authProtocol: snmp.AuthProtocols.sha,
  70. authKey: "illhavesomeauth",
  71. privProtocol: snmp.PrivProtocols.des,
  72. privKey: "andsomepriv"
  73. },
  74. });
  75. forwarder.dumpProxies ();