mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 19:21:46 +00:00
Symptoms: ``` extras/dialer/time-scope-probe-cgroup:31:18: arithmetic expressions must consist of names and numbers extras/dialer/time-scope-probe-cgroup: run shfmt -i 4 -w extras/dialer/time-scope-probe-cgroup extras/dialer/time-scope-probe-proc:28:18: arithmetic expressions must consist of names and numbers extras/dialer/time-scope-probe-proc: run shfmt -i 4 -w extras/dialer/time-scope-probe-proc extras/in_parallel.sh:29:16: arithmetic expressions must consist of names and numbers extras/in_parallel.sh: run shfmt -i 4 -w extras/in_parallel.sh ``` Visible on https://circleci.com/gh/kinvolk/scope/980
42 lines
1.0 KiB
Bash
Executable File
42 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
if [ $EUID -ne 0 ]; then
|
|
echo "You must be root!" >&2
|
|
exit 1
|
|
fi
|
|
|
|
readonly interval_num=${1:-60}
|
|
readonly interval_sleep=${2:-10}
|
|
|
|
readonly container_id="${3:-$(sudo docker inspect weavescope | jq -r .[].Id)}"
|
|
readonly cpuacct_stat="/sys/fs/cgroup/cpu,cpuacct/docker/${container_id}/cpuacct.stat"
|
|
|
|
TIME_U1=0
|
|
TIME_K1=0
|
|
TIME_T1=0
|
|
TIME_U2=0
|
|
TIME_K2=0
|
|
TIME_T2=0
|
|
|
|
if [ "$(pidof scope-probe)" == "" ]; then
|
|
echo "No scope-probe process running - aborting" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TIME_U2=$(awk '/user/ {print $2}' "${cpuacct_stat}")
|
|
TIME_K2=$(awk '/system/ {print $2}' "${cpuacct_stat}")
|
|
TIME_T2=$((TIME_U2 + TIME_K2))
|
|
|
|
echo "utime;stime;total_time"
|
|
for ((i = 0; i < interval_num; i++)); do
|
|
sleep "$interval_sleep"
|
|
TIME_U1=$TIME_U2
|
|
TIME_K1=$TIME_K2
|
|
TIME_T1=$TIME_T2
|
|
|
|
TIME_U2=$(awk '/user/ {print $2}' "${cpuacct_stat}")
|
|
TIME_K2=$(awk '/system/ {print $2}' "${cpuacct_stat}")
|
|
TIME_T2=$((TIME_U2 + TIME_K2))
|
|
echo "$((TIME_U2 - TIME_U1));$((TIME_K2 - TIME_K1));$((TIME_T2 - TIME_T1))"
|
|
done
|