Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e -u -o pipefail
- ## replicatedctl is an awkward wrapper around docker, and tty detection is a
- ## little wonky
- exec 0<&-
- ## collects logs and other diagnostics to aid in troubleshooting failed tests
- if ! jq -n -e true >/dev/null ; then
- echo "jq is required to generate this diag bundle"
- exit 1
- fi
- pushd "$( mktemp -d )" >/dev/null
- journalctl > journal.log
- ## attempt to generate a support bundle
- ## > Support bundle file created at /var/lib/replicated/support-bundles/replicated-support507489213.tar.gz\r
- if bundle=$( replicatedctl support-bundle 2>/dev/null | tr -d '\r' | awk '{print $NF}' ); then
- mv "${bundle}" ./replicated-support.tgz
- else
- echo "unable to capture Replicated support bundle"
- fi
- if ! replicatedctl app-config export > app-config.json ; then
- echo "unable to capture app config"
- fi
- if docker info >/dev/null 2>&1 ; then
- mkdir container_logs
- if ! docker ps -a | tail -n +2 | awk '{print $NF}' | xargs docker inspect > docker-inspect.json ; then
- echo "error inspecting some containers"
- fi
- while read -r container_id container_name ; do
- if ! docker logs --timestamps "${container_id}" > "container_logs/${container_name}.log" 2>&1 ; then
- echo "unable to collect logs from ${container_id} (${container_name})"
- fi
- done < <( jq -r '.[] | [.Id, .Name[1:]] | @tsv' docker-inspect.json )
- else
- echo "unable to capture docker logs"
- fi
- bundle="/tmp/diag-bundle.tgz"
- rm -f "${bundle}"
- tar -czf ${bundle} .
- chmod 666 ${bundle}
- echo "created ${bundle}"
Add Comment
Please, Sign In to add comment