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.

specify-sysuptime-to-trap.js 915B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2013 Stephen Vickers
  2. var dns = require ("dns");
  3. var os = require ("os");
  4. var snmp = require ("../");
  5. if (process.argv.length < 7) {
  6. console.log ("usage: node specify-sysuptime-to-trap <target> <community>\n"
  7. + " <version> <typeOrOid> <sysuptime>");
  8. process.exit (1);
  9. }
  10. var target = process.argv[2];
  11. var community = process.argv[3];
  12. var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
  13. var typeOrOid = process.argv[5];
  14. var upTime = parseInt(process.argv[6]);
  15. var session = snmp.createSession (target, community, {version: version});
  16. dns.lookup (os.hostname (), function (error, address) {
  17. if (error) {
  18. console.trace (error);
  19. } else {
  20. // address will be ignored for version 2c
  21. session.trap (snmp.TrapType[typeOrOid] || parseInt(typeOrOid),
  22. {upTime: upTime}, function (error) {
  23. if (error)
  24. console.trace ("Trap failed: " + error);
  25. });
  26. }
  27. });