Created
June 26, 2018 15:28
-
-
Save topherbullock/954f948f0d69430830e3b6dd9b3fd796 to your computer and use it in GitHub Desktop.
Concourse Last Will and Testament Collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -z $1 ]]; then | |
director_env="prod" | |
else | |
director_env=$1 | |
fi | |
if [[ -z $2 ]]; then | |
deployment="concourse-wings" | |
else | |
deployment=$2 | |
fi | |
if [[ -z $3 ]]; then | |
instance="web" | |
else | |
instance=$3 | |
fi | |
set -e -u | |
dumpdate=$(date +%Y-%m-%d) | |
dump_prefix="/tmp/dump.${dumpdate}" | |
echo -e "Authenticating with bosh director\n" | |
echo "Taking a Stack Dump From ${instance}" | |
command='sudo bash -c "curl -s 0.0.0.0:8079/debug/pprof/goroutine?debug=2 > '${dump_prefix}'.$(hostname).log"' | |
bosh -n -e $director_env -d $deployment ssh -c "$command" $instance | |
echo "Copying Over Stack Dump Files" | |
bosh -n -e $director_env -d $deployment scp $instance:$dump_prefix*.log ./ | |
echo "Flushing Files From Hosts" | |
bosh -n -e $director_env -d $deployment ssh -c "sudo bash -c 'rm ${dump_prefix}.*.log'" $instance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment