Created
July 7, 2022 16:18
-
-
Save Oats87/94f431165de4603db0c927dbf767fa84 to your computer and use it in GitHub Desktop.
Collect pprof for Rancher in K8s
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
#!/bin/sh | |
for pod in $(kubectl get pods --no-headers -l app=rancher -n cattle-system | cut -d ' ' -f1); do | |
echo Collecting pprof information for $pod - this will take some time. | |
kubectl -n cattle-system exec $pod -c rancher -- curl -s http://localhost:6060/debug/pprof/profile -o profile; | |
kubectl -n cattle-system cp $pod:profile pprof-$pod-profile -c rancher; | |
kubectl -n cattle-system exec $pod -c rancher -- curl -s http://localhost:6060/debug/pprof/goroutine -o goroutine; | |
kubectl -n cattle-system cp $pod:goroutine pprof-$pod-goroutine -c rancher; | |
kubectl -n cattle-system exec $pod -c rancher -- curl -s http://localhost:6060/debug/pprof/heap -o heap; | |
kubectl -n cattle-system cp $pod:heap pprof-$pod-heap -c rancher; | |
kubectl -n cattle-system exec $pod -c rancher -- curl -s http://localhost:6060/debug/pprof/threadcreate -o threadcreate; | |
kubectl -n cattle-system cp $pod:threadcreate pprof-$pod-threadcreate -c rancher; | |
kubectl -n cattle-system exec $pod -c rancher -- curl -s http://localhost:6060/debug/pprof/block -o block; | |
kubectl -n cattle-system cp $pod:block pprof-$pod-block -c rancher; | |
kubectl -n cattle-system exec $pod -c rancher -- curl -s http://localhost:6060/debug/pprof/mutex -o mutex; | |
kubectl -n cattle-system cp $pod:mutex pprof-$pod-mutex -c rancher; | |
echo Collection of pprof information for $pod complete | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment