Created
July 21, 2020 18:28
-
-
Save mwmitchell/37540882b0713307a702e214899a5ea9 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
DIR=$(dirname "$0") | |
NS=$($DIR/current-namespace) | |
PODS=$(kubectl -n $NS get pods -l app.kubernetes.io/name=rpc-service -o name) | |
for pod in $PODS; do | |
tstamp=$(date +%s) | |
echo "Creating dump files pod=$pod using timestamp=$tstamp" | |
cmd='pid=$(jps | grep -i rpc | cut -d " " -f1) && cd /dumps && jstack $pid > ' $tstamp '.stack && jmap -dump:live,format=b,file=' $tstamp '.hprof $pid && tar -cf ' $tstamp '.hprof.tar ' $tstamp '.hprof' | |
kubectl exec -n $NS -ti $pod -- /bin/bash -c $cmd | |
kubectl cp -n $N $pod:/dumps/$tstamp.hprof.tar $pod-$tstamp.hprof.tar | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment