github.com/braveheart12/insolar-09-08-19@v0.8.7/scripts/insolard/profile.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Example of profiling 60 second profile on all insolard node
     4  # (by default profiles 30 seconds):
     5  #
     6  # ./scripts/insolard/profile.sh [60]
     7  
     8  prof_time=${1:-"30"}
     9  prof_files_dir=pprof
    10  current_dir=$( dirname $0 )
    11  web_profile_port=8080
    12  
    13  trap 'killall' INT TERM EXIT
    14  
    15  killall() {
    16      trap '' INT TERM     # ignore INT and TERM while shutting down
    17      echo "Shutting down..."
    18      kill -TERM 0         # fixed order, send TERM not INT
    19      wait
    20      echo DONE
    21  }
    22  
    23  confs=${current_dir}"/configs/generated_configs/*nodes/insolar_*.yaml"
    24  prof_ports=$( grep listenaddress ${confs} |  grep -o ":\d\+" | grep -o "\d\+" | tr '\n' ' ' )
    25  
    26  mkdir -p ${current_dir}/${prof_files_dir}
    27  
    28  echo "Fetching profile data from insolar nodes..."
    29  for port in ${prof_ports}
    30  do
    31      curl "http://localhost:${port}/debug/pprof/profile?seconds=${prof_time}" --output ${current_dir}/${prof_files_dir}/prof_${port} &> /dev/null &
    32  done
    33  wait
    34  
    35  echo "Starting web servers with profile info..."
    36  
    37  i=${web_profile_port}
    38  for port in ${prof_ports}
    39  do
    40      go tool pprof -http=:${i} ${current_dir}/${prof_files_dir}/prof_${port} &
    41      echo "Started web profile server on localhost:${i}/ui"
    42      i=$((i + 1))
    43  done
    44  wait