summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2024-10-30 17:00:20 +0800
committerluwenpeng <[email protected]>2024-11-01 15:24:22 +0800
commitd56cda3d9aadff2bb98529467452d7097bd167cc (patch)
tree64f46a11c555bdf8d13e3671d3fab2b6dde8954e /scripts
parent03864c9731ec87ed6c7e1fbe3c5f261880e857dc (diff)
session manager support output fieldstat
Diffstat (limited to 'scripts')
-rw-r--r--scripts/CMakeLists.txt3
-rw-r--r--scripts/python_stat.sh3
-rw-r--r--scripts/shell_stat.sh59
-rw-r--r--scripts/stat_format.sh9
4 files changed, 10 insertions, 64 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 7243c1d..af17de6 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -1,2 +1 @@
-install(FILES python_stat.sh DESTINATION ./ COMPONENT PROGRAM)
-install(FILES shell_stat.sh DESTINATION ./ COMPONENT PROGRAM) \ No newline at end of file
+install(FILES stat_format.sh DESTINATION ./ COMPONENT PROGRAM) \ No newline at end of file
diff --git a/scripts/python_stat.sh b/scripts/python_stat.sh
deleted file mode 100644
index 2cfb69b..0000000
--- a/scripts/python_stat.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-/opt/MESA/bin/fieldstat_exporter.py local -j /opt/tsg/stellar/log/stellar_fs4.json -l --clear-screen -e
diff --git a/scripts/shell_stat.sh b/scripts/shell_stat.sh
deleted file mode 100644
index 056f882..0000000
--- a/scripts/shell_stat.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash +x
-
-#cat stellar_fs4.json |jq
-#[
-# {
-# "name": "stellar",
-# "tags": {},
-# "fields": {
-# "aaaa": 1111111,
-# "bbbb": 2222222,
-# },
-# "timestamp_ms": 1713053113549
-# }
-#]
-
-calculate() {
- local curr_data=$1
- local prev_data=$2
-
- local fields=($(echo "$curr_data" | jq -r '.[].fields | to_entries | .[] | .key' | grep -v timestamp_ms))
- local curr_ts=$(echo "$curr_data" | jq -r '.[].timestamp_ms')
- local prev_ts=$(echo "$prev_data" | jq -r '.[].timestamp_ms')
- local diff_ts=$(($curr_ts - $prev_ts))
- local seconds=$((curr_ts / 1000))
- local buffer=()
-
- local curr_fileds=$(echo "$curr_data" | jq -r '.[].fields' | grep -v timestamp_ms)
- local prev_fileds=$(echo "$prev_data" | jq -r '.[].fields' | grep -v timestamp_ms)
-
- buffer+=("====================================$(date -d "@$seconds" +"%Y-%m-%d %H:%M:%S")====================================\n")
- buffer+=("$(printf "%-30s" Field)$(printf "%-20s" Sum)$(printf "%-20s" Speed)\n")
- local result=()
- for field in "${fields[@]}"; do
- local curr_val=$(echo "$curr_fileds" | grep $field | awk '{print $2}' | sed 's/,//g')
- local prev_val=$(echo "$prev_fileds" | grep $field | awk '{print $2}' | sed 's/,//g')
- local diff_val=$((curr_val - prev_val))
- local speed=0
- if [ $diff_ts -eq 0 ]; then
- speed=0
- else
- speed=$((diff_val * 1000 / diff_ts))
- fi
- buffer+=("$(printf "%-30s" $field)$(printf "%-20s" $curr_val)$(printf "%-20s" $speed)\n")
- done
- buffer+=("===========================================================================================\n")
- clear
- echo -e "${buffer[@]}"
-}
-
-prev_data=""
-
-while true; do
- curr_data=$(cat /opt/tsg/stellar/log/stellar_fs4.json)
- if [ ! -z "$prev_data" ]; then
- calculate "$curr_data" "$prev_data"
- fi
- prev_data="$curr_data"
- sleep 1
-done
diff --git a/scripts/stat_format.sh b/scripts/stat_format.sh
new file mode 100644
index 0000000..999e839
--- /dev/null
+++ b/scripts/stat_format.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 <f4_json_file>"
+ exit 1
+fi
+
+f4_json_file=$1
+/opt/MESA/bin/fieldstat_exporter.py local -j $f4_json_file -l --clear-screen