xref: /redis-3.2.3/utils/whatisdoing.sh (revision 5b2bbef9)
1# This script is from http://poormansprofiler.org/
2#
3# NOTE: Instead of using this script, you should use the Redis
4# Software Watchdog, which provides a similar functionality but in
5# a more reliable / easy to use way.
6#
7# Check http://redis.io/topics/latency for more information.
8
9#!/bin/bash
10nsamples=1
11sleeptime=0
12pid=$(ps auxww | grep '[r]edis-server' | awk '{print $2}')
13
14for x in $(seq 1 $nsamples)
15  do
16    gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
17    sleep $sleeptime
18  done | \
19awk '
20  BEGIN { s = ""; }
21  /Thread/ { print s; s = ""; }
22  /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
23  END { print s }' | \
24sort | uniq -c | sort -r -n -k 1,1
25