whatisdoing.sh 428 B

123456789101112131415161718
  1. # This script is from http://poormansprofiler.org/
  2. #!/bin/bash
  3. nsamples=1
  4. sleeptime=0
  5. pid=$(pidof redis-server)
  6. for x in $(seq 1 $nsamples)
  7. do
  8. gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
  9. sleep $sleeptime
  10. done | \
  11. awk '
  12. BEGIN { s = ""; }
  13. /Thread/ { print s; s = ""; }
  14. /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
  15. END { print s }' | \
  16. sort | uniq -c | sort -r -n -k 1,1