25 lines
941 B
Plaintext
Executable File
25 lines
941 B
Plaintext
Executable File
|
|
# pod=analytics-84d4bff6c-2fzj9
|
|
namespace=us2-analytics
|
|
|
|
echo "getting pods..."
|
|
pods=`kubectl get pods -n $namespace`
|
|
totalpods=$(echo $pods | wc -l)
|
|
totalpods="$((totalpods-1))"
|
|
echo $pods | awk "NR==1" | awk '$0=" "$0'
|
|
echo $pods | awk "NR>1" | awk '$0=NR") "$0'
|
|
echo "> Please select one of the pods, enter a number between 1 and $totalpods"
|
|
read pod_num
|
|
|
|
case ${pod_num#[-+]} in
|
|
*[!0-9]* | '') echo "Must be an integer." ;;
|
|
esac
|
|
|
|
pod=$(kubectl get pods -n $namespace | awk {'print $1}' | awk -v pod_num=$pod_num 'NR==pod_num+1')
|
|
echo "Getting memory dump for $pod - Continue? [ANY KEY]..."
|
|
read
|
|
kubectl exec -n $namespace $pod -c analytics-assembly -- jcmd Bootstrap GC.heap_dump /tmp/$pod.hprof
|
|
kubectl exec -n $namespace $pod -c analytics-assembly -- gzip /tmp/$pod.hprof
|
|
kubectl -n $namespace cp -c analytics-assembly $pod:/tmp/$pod.hprof.gz $pod.hprof.gz
|
|
|
|
kubectl exec -n $namespace $pod -c analytics-assembly -it -- /bin/bash |