export_pprof_goroutine.sh 746 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # Exit immediately for non zero status
  3. set -e
  4. ns_name=$1
  5. instance_name=$2
  6. log_dir=${3:-"k8s_logs"}
  7. # export goroutine of all milvus pods
  8. array=($(kubectl get pod -n ${ns_name} -l "app.kubernetes.io/instance=${instance_name}, app.kubernetes.io/name=milvus"| awk 'NR == 1 {next} {print $1}'))
  9. echo ${array[@]}
  10. if [ ! -d $log_dir/goroutine ];
  11. then
  12. mkdir -p $log_dir/goroutine
  13. fi
  14. echo "export goroutine start"
  15. for pod in ${array[*]}
  16. do
  17. echo "export goroutine for pod $pod "
  18. ip=($(kubectl get pod ${pod} -n ${ns_name} -o jsonpath='{.status.podIP}'))
  19. echo $ip
  20. curl "http://${ip}:9091/debug/pprof/goroutine?debug=10" -o ./$log_dir/goroutine/$pod.log || echo "export goroutine for pod $pod failed"
  21. done
  22. echo "export goroutine done"