node_dump 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. {
  28. collect bin/emqx eval "'emqx_node_dump:app_env_dump()'"
  29. } > log/conf.dump
  30. # Collect log files that are not older than 3 days:
  31. LOGS=$(find log -mtime -3 \( -name '*.log.*' -or -name 'run_erl.log*' \))
  32. tar czf "${DUMP}" ${LOGS} \
  33. log/sysinfo.txt \
  34. log/conf.dump
  35. ## Cleanup:
  36. rm log/sysinfo.txt
  37. #rm log/conf.dump # Keep it for inspection
  38. echo "Created a node dump ${DUMP}"
  39. echo -e "\nWARNING: this script tries to obfuscate secrets, but make sure to
  40. inspect log/conf.dump file manually before uploading the node dump
  41. to a public location."