Example Linux shell process

1. Linux shell process example

1.1. pyroscope

wget https://xxx.aliyuncs.com/third-party/pyroscope/pyroscope-0.36.0-linux-amd64.tar.gz -O /tmp/pyroscope-0.36.0-linux-amd64.tar.gz
tar -zxvf /tmp/pyroscope-0.36.0-linux-amd64.tar.gz -C /tmp
cp /tmp/tmp/run_py.sh /tmp/run_py.sh
chmod +x /tmp/*.sh
nohup /tmp/run_py.sh  > /tmp/1.log 2>&1 &
/usr/local/datakit/datakit --docker
# Belowing is for profile the specific process.
run_py.sh: |-
  #!/bin/sh
  sleep 10s
  read pid < /usr/local/datakit/.pid
  /tmp/pyroscope connect --pid $pid
# Belowing is for profile the specific processes.
run_py.sh: |-
    #!/bin/bash
    sleep 10s
    readarray -t my_array < <(pgrep $TARGET_NAME)
    length=${
    
    #my_array[@]}
    echo $length
    for (( i=0; i<length; i++ ));
    do
    id=${my_array[$i]}
    echo $id
    nohup /tmp/pyroscope connect --pid $id > /tmp/$id.log 2>&1 &
    done
# Belowing is for profile the whole system.
run_py.sh: |-
  #!/bin/sh
  sleep 10s
  /tmp/pyroscope ebpf

Guess you like

Origin blog.csdn.net/wan212000/article/details/129731920