node_dump 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. set -euo pipefail
  3. shopt -s nullglob
  4. ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
  5. echo "Running node dump in ${ROOT_DIR}"
  6. cd "${ROOT_DIR}"
  7. DUMP="log/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz"
  8. collect() {
  9. echo "========================================================"
  10. echo " $*"
  11. echo "========================================================"
  12. eval "$*" || echo "Unavailable"
  13. echo -e '\n'
  14. }
  15. {
  16. collect bin/emqx_ctl broker
  17. collect bin/emqx eval "'emqx_node_dump:sys_info()'"
  18. collect uname -a
  19. collect uptime
  20. collect free -h
  21. collect netstat -tnl
  22. collect bin/emqx_ctl plugins list
  23. collect bin/emqx_ctl modules list
  24. collect bin/emqx_ctl vm all
  25. collect bin/emqx_ctl listeners
  26. } > log/sysinfo.txt
  27. bin/emqx eval 'emqx_node_dump:app_env_dump()' > log/conf.dump
  28. tar czf "${DUMP}" log/*.log.* log/run_erl.log* log/sysinfo.txt log/conf.dump
  29. ## Cleanup:
  30. rm log/sysinfo.txt
  31. #rm log/conf.dump
  32. echo "Created a node dump ${DUMP}"
  33. echo -e "\nWarning: this script tries to obfuscate secrets, but make sure to
  34. inspect log/conf.dump file manually before uploading the node dump
  35. to a public location."