Guest User

Untitled

a guest
Jul 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #!/bin/bash
  2. set -e -u -o pipefail
  3.  
  4. ## replicatedctl is an awkward wrapper around docker, and tty detection is a
  5. ## little wonky
  6. exec 0<&-
  7.  
  8. ## collects logs and other diagnostics to aid in troubleshooting failed tests
  9.  
  10. if ! jq -n -e true >/dev/null ; then
  11. echo "jq is required to generate this diag bundle"
  12. exit 1
  13. fi
  14.  
  15. pushd "$( mktemp -d )" >/dev/null
  16.  
  17. journalctl > journal.log
  18.  
  19. ## attempt to generate a support bundle
  20. ## > Support bundle file created at /var/lib/replicated/support-bundles/replicated-support507489213.tar.gz\r
  21. if bundle=$( replicatedctl support-bundle 2>/dev/null | tr -d '\r' | awk '{print $NF}' ); then
  22. mv "${bundle}" ./replicated-support.tgz
  23. else
  24. echo "unable to capture Replicated support bundle"
  25. fi
  26.  
  27. if ! replicatedctl app-config export > app-config.json ; then
  28. echo "unable to capture app config"
  29. fi
  30.  
  31. if docker info >/dev/null 2>&1 ; then
  32. mkdir container_logs
  33.  
  34. if ! docker ps -a | tail -n +2 | awk '{print $NF}' | xargs docker inspect > docker-inspect.json ; then
  35. echo "error inspecting some containers"
  36. fi
  37.  
  38. while read -r container_id container_name ; do
  39. if ! docker logs --timestamps "${container_id}" > "container_logs/${container_name}.log" 2>&1 ; then
  40. echo "unable to collect logs from ${container_id} (${container_name})"
  41. fi
  42. done < <( jq -r '.[] | [.Id, .Name[1:]] | @tsv' docker-inspect.json )
  43. else
  44. echo "unable to capture docker logs"
  45. fi
  46.  
  47. bundle="/tmp/diag-bundle.tgz"
  48.  
  49. rm -f "${bundle}"
  50. tar -czf ${bundle} .
  51. chmod 666 ${bundle}
  52.  
  53. echo "created ${bundle}"
Add Comment
Please, Sign In to add comment