diff options
Diffstat (limited to 'extras/devel-tools')
| -rwxr-xr-x | extras/devel-tools/print-backtrace.sh | 27 | ||||
| -rwxr-xr-x | extras/devel-tools/strace-brick.sh | 55 |
2 files changed, 71 insertions, 11 deletions
diff --git a/extras/devel-tools/print-backtrace.sh b/extras/devel-tools/print-backtrace.sh index 72b93c1353f..33fbae288bc 100755 --- a/extras/devel-tools/print-backtrace.sh +++ b/extras/devel-tools/print-backtrace.sh @@ -40,9 +40,11 @@ if [ ! $debuginfo_rpm ] || [ ! $backtrace_file ]; then exit 1 fi -if [ $debuginfo_rpm != "none" ] && [ ! -f $debuginfo_rpm ]; then - echo "no such rpm file: $debuginfo_rpm" - exit 1 +if [ $debuginfo_rpm != "none" ]; then + if [ ! -f $debuginfo_rpm ]; then + echo "no such rpm file: $debuginfo_rpm" + exit 1 + fi fi if [ ! -f $backtrace_file ]; then @@ -50,9 +52,11 @@ if [ ! -f $backtrace_file ]; then exit 1 fi -if ! file $debuginfo_rpm | grep RPM >/dev/null 2>&1 ; then - echo "file does not look like an rpm: $debuginfo_rpm" - exit 1 +if [ "$debuginfo_rpm" != "none" ]; then + if ! file $debuginfo_rpm | grep RPM >/dev/null 2>&1 ; then + echo "file does not look like an rpm: $debuginfo_rpm" + exit 1 + fi fi cpio_version=$(cpio --version|grep cpio|cut -f 2 -d ')'|sed -e 's/^[[:space:]]*//') @@ -92,15 +96,16 @@ else fi # NOTE: backtrace file should contain only the lines which need to be resolved -for bt in $(grep glusterfs $backtrace_file) +for bt in $(cat $backtrace_file) do libname=$(echo $bt | cut -f 1 -d '(') addr=$(echo $bt | cut -f 2 -d '(' | cut -f 1 -d ')') - # only unresolved addresses start with a '+' - if echo $addr | egrep '^\+' >/dev/null 2>&1 ; then - newbt=( $(eu-addr2line --functions --exe=${debuginfo_path}${libname}${debuginfo_extension} $addr) ) - echo "$bt ${newbt[*]}" + libpath=${debuginfo_path}${libname}${debuginfo_extension} + if [ ! -f $libpath ]; then + continue fi + newbt=( $(eu-addr2line --functions --exe=$libpath $addr) ) + echo "$bt ${newbt[*]}" done # remove the temporary directory diff --git a/extras/devel-tools/strace-brick.sh b/extras/devel-tools/strace-brick.sh new file mode 100755 index 00000000000..a140729111c --- /dev/null +++ b/extras/devel-tools/strace-brick.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Usage: +# nice -n -19 strace-brick.sh glusterfsd 50 + +brick_process_name=$1 +min_watch_cpu=$2 +if [ ! $brick_process_name ]; then + brick_process_name=glusterfsd +fi + +if [ ! $min_watch_cpu ]; then + min_watch_cpu=50 +fi + +echo "min_watch_cpu: $min_watch_cpu" + +break=false + +while ! $break; +do + mypids=( $(pgrep $brick_process_name) ) + echo "mypids: ${mypids[*]}" + + pid_args=$(echo ${mypids[*]} | sed -e 's/ / -p /g;s/^/-p /') + echo "pid_args: $pid_args" + + pcpu=( $(ps $pid_args -o pcpu -h ) ) + echo "pcpu: ${pcpu[*]}" + + wait_longer=false + + for i in $( seq 0 $((${#pcpu[*]} - 1)) ) + do + echo "i: $i" + echo "mypids[$i]: ${mypids[$i]}" + + int_pcpu=$(echo ${pcpu[$i]} | cut -f 1 -d '.') + echo "int_pcpu: $int_pcpu" + if [ ! $int_pcpu ] || [ ! $min_watch_cpu ]; then + break=true + echo "breaking" + fi + if [ $int_pcpu -ge $min_watch_cpu ]; then + wait_longer=true + mydirname="${brick_process_name}-${mypids[$i]}-$(date --utc +'%Y%m%d-%H%M%S.%N')" + $(mkdir $mydirname && cd $mydirname && timeout --kill-after=5 --signal=KILL 60 nice -n -19 strace -p ${mypids[$i]} -ff -tt -T -o $brick_process_name) & + fi + done + + if $wait_longer; then + sleep 90 + else + sleep 15 + fi +done |
