-
Notifications
You must be signed in to change notification settings - Fork 4
/
pprof.sh
executable file
·56 lines (47 loc) · 1.89 KB
/
pprof.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
seconds=${1:-60}
label=${2:-pprof}
logdir=${3:-./logs}
interval=5
host=localhost
list='orderer1 org1-peer1 dev-peer1.org1.example.com-ccperf-v1'
export http_proxy="http://$host:8888"
collect_start() {
t=$(date -u +%s)
for target in $list; do
(
curl -s "http://$target:6060/debug/pprof/wakeup?debug=2&rate=1000" > "$logdir/$label-wakeup-$target-$t.json"
curl -s "http://$target:6060/debug/pprof/wakeup" > "$logdir/$label-wakeup-$target-$t.pb"
curl -s "http://$target:6060/debug/pprof/block?seconds=$seconds&rate=1000" > "$logdir/$label-block-$target.pb" &
curl -s "http://$target:6060/debug/pprof/profile?seconds=$seconds" > "$logdir/$label-cpu-$target.pb" &
) &
done
}
collect_end() {
t=$(date -u +%s)
for target in $list; do
(
curl -s "http://$target:6060/debug/pprof/wakeup?debug=2" > "$logdir/$label-wakeup-$target-$t.json"
curl -s "http://$target:6060/debug/pprof/wakeup" > "$logdir/$label-wakeup-$target-$t.pb"
#curl -s "http://$target:6060/debug/pprof/block" > "$logdir/$label-block-$target-$t.pb"
) &
done
}
collect_start
while [[ $seconds > 0 ]] && [[ -z "$finish" ]] ; do
t=$(date -u +%s)
for target in $list; do
curl -s "http://org1-peer1:6060/debug/pprof/goroutine?debug=2" > "$logdir/$label-goroutines-$target-$t.json" &
done
(( seconds -= $interval ))
sleep $interval || break
done
collect_end
wait
for target in $list; do
if [ -x ./go-bottleneck ]; then
./go-bottleneck "$logdir"/$label-goroutines-$target-*.json "$logdir"/$label-wakeup-$target-*.json > "$logdir"/$label-$target.dot
dot -Tpdf "$logdir"/$label-$target.dot > "$logdir"/$label-$target.pdf
fi
[ -d bin/FlameGraph ] && go tool pprof -raw "$logdir/$label-cpu-$target.pb" | bin/FlameGraph/stackcollapse-go.pl | bin/FlameGraph/flamegraph.pl > "$logdir/$label-cpu-$target.svg"
done