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.

specify-sysuptime-to-inform.js 841B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2013 Stephen Vickers
  2. var snmp = require ("../");
  3. if (process.argv.length < 6) {
  4. console.log ("usage: specify-sysuptime-to-inform <target> <community> <oid> <sysuptime>");
  5. process.exit (1);
  6. }
  7. var target = process.argv[2];
  8. var community = process.argv[3];
  9. var typeOrOid = process.argv[4];
  10. var upTime = parseInt(process.argv[5]);
  11. var options = {version: snmp.Version2c};
  12. var session = snmp.createSession (target, community, options);
  13. session.inform (snmp.TrapType[typeOrOid] || typeOrOid, {upTime: upTime},
  14. function (error, varbinds) {
  15. if (error) {
  16. console.error (error.toString ());
  17. } else {
  18. for (var i = 0; i < varbinds.length; i++) {
  19. if (snmp.isVarbindError (varbinds[i]))
  20. console.error (snmp.varbindError (varbinds[i]));
  21. else
  22. console.log (varbinds[i].oid + "|" + varbinds[i].value);
  23. }
  24. }
  25. });