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.

receiver-test.sh 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. # receiver-test.sh - run tests for the net-snmp Receiver
  3. # Usage: receiver-test.sh [ -6 ] [ -e <engine-id> ] [ -h ] [ -p ] [ -t target ]
  4. HOME_DIR=.
  5. HOST=localhost
  6. PRINT_ONLY=0
  7. CMDS=/var/tmp/receiver-test.$$
  8. TRAP_OID="1.3.6.1.6.3.1.1.5.2"
  9. unset ENGINE_ID
  10. IPV6=0
  11. # Auth parameters - change as necessary
  12. COMMUNITY=public
  13. USER_NONE=fred
  14. USER_AUTH=betty
  15. USER_PRIV=barney
  16. AUTH_PROTOCOL=sha
  17. AUTH_KEY=illhavesomeauth
  18. PRIV_PROTOCOL=aes
  19. PRIV_KEY=andsomepriv
  20. usage() {
  21. echo "Usage: $0 [ -6 ] [ -e <engine-id> ] [ -h ] [ -p ] [ -t target ]"
  22. echo
  23. echo "Options:"
  24. echo " -6 use IPv6"
  25. echo " -e <engine-id> engine ID - used for SNMPv3 traps only"
  26. echo " -h print usage message and exit"
  27. echo " -p print commands but do not run them"
  28. echo " -t <host> target host"
  29. exit 1
  30. }
  31. while getopts "6e:hl:pt:" OPT ; do
  32. case ${OPT} in
  33. 6) IPV6=1 ;;
  34. e) ENGINE_ID=${OPTARG} ;;
  35. h) usage ;;
  36. p) PRINT_ONLY=1 ;;
  37. t) HOST=${OPTARG} ;;
  38. esac
  39. done
  40. shift $((OPTIND - 1))
  41. PARAMS=""
  42. if [[ -n ${ENGINE_ID} ]] ; then
  43. PARAMS="${PARAMS} -e \"${ENGINE_ID}\""
  44. fi
  45. if (( IPV6 )) ; then
  46. PARAMS="${PARAMS} -t udp6"
  47. fi
  48. cat >>${CMDS} <<ENDOFCMDS
  49. node ${HOME_DIR}/example/snmp-trap.js -v 1 -c ${COMMUNITY} ${PARAMS} ${HOST} ${TRAP_OID}
  50. node ${HOME_DIR}/example/snmp-trap.js -v 2c -c ${COMMUNITY} ${PARAMS} ${HOST} ${TRAP_OID}
  51. node ${HOME_DIR}/example/snmp-trap.js -v 3 -l noAuthNoPriv -u ${USER_NONE} ${PARAMS} ${HOST} ${TRAP_OID}
  52. node ${HOME_DIR}/example/snmp-trap.js -v 3 -l authNoPriv -u ${USER_AUTH} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
  53. node ${HOME_DIR}/example/snmp-trap.js -v 3 -l authPriv -u ${USER_PRIV} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
  54. node ${HOME_DIR}/example/snmp-inform.js -v 2c -c ${COMMUNITY} ${PARAMS} ${HOST} ${TRAP_OID}
  55. node ${HOME_DIR}/example/snmp-inform.js -v 3 -l noAuthNoPriv -u ${USER_NONE} ${PARAMS} ${HOST} ${TRAP_OID}
  56. node ${HOME_DIR}/example/snmp-inform.js -v 3 -l authNoPriv -u ${USER_AUTH} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
  57. node ${HOME_DIR}/example/snmp-inform.js -v 3 -l authPriv -u ${USER_PRIV} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
  58. ENDOFCMDS
  59. COUNT=1
  60. while read CMD ; do
  61. if (( PRINT_ONLY )) ; then
  62. echo ${CMD}
  63. else
  64. CMD_NAME=$(echo ${CMD} | awk '{print $2}' | xargs basename)
  65. echo "${COUNT}. ${CMD_NAME}"
  66. echo ${CMD}
  67. eval ${CMD}
  68. echo
  69. fi
  70. COUNT=$((COUNT+1))
  71. done <${CMDS}
  72. rm -f ${CMDS}