aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/datafilecollector-testharness/simulator-group/dfc-internal-stats.sh
diff options
context:
space:
mode:
authorBjornMagnussonXA <bjorn.magnusson@est.tech>2019-07-17 08:26:50 +0000
committerBjornMagnussonXA <bjorn.magnusson@est.tech>2019-07-17 08:26:50 +0000
commita79a043b5a99fa05e9f73559ff1c3b2e36bd70c0 (patch)
tree68467182b78b7ac58f183483ecd97749ef4e824a /test/mocks/datafilecollector-testharness/simulator-group/dfc-internal-stats.sh
parentc98471c6541573d73edc677272f23e06c6c28dbc (diff)
Added support for Consul/CBS and multiple DFCs
Issue-ID: INT-1155 Change-Id: I3c1ed2f6072655c4396e406ddfd490d3786fe4d6 Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Diffstat (limited to 'test/mocks/datafilecollector-testharness/simulator-group/dfc-internal-stats.sh')
-rwxr-xr-xtest/mocks/datafilecollector-testharness/simulator-group/dfc-internal-stats.sh103
1 files changed, 103 insertions, 0 deletions
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/dfc-internal-stats.sh b/test/mocks/datafilecollector-testharness/simulator-group/dfc-internal-stats.sh
new file mode 100755
index 000000000..9fbe9615c
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/simulator-group/dfc-internal-stats.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+# Script to print internal dfc stats every 5 sec to screen and file
+# Default port is 8100 for DFC
+# Useage: ./dfc-internal-stats.sh all|internal|jvm [<dfc-port-number>]
+
+print_usage() {
+ echo "Useage: ./dfc-internal-stats.sh all|internal|jvm [<dfc-port-number>]"
+}
+stat=""
+if [ $# -eq 0 ]; then
+ dfcport=8100
+ stat="all"
+elif [ $# -eq 1 ]; then
+ dfcport=8100
+ stat=$1
+elif [ $# -eq 2 ]; then
+ dfcport=$2
+ stat=$1
+else
+ print_usage
+ exit 1
+fi
+
+heading=1
+
+if [ $stat == "all" ]; then
+ echo "Printing stats for both JVM and DFC using port "$dfcport
+elif [ $stat == "internal" ]; then
+ echo "Printing stats for DFC using port "$dfcport
+elif [ $stat == "jvm" ]; then
+ echo "Printing stats for JVM using port "$dfcport
+else
+ print_usage
+ exit 1
+fi
+fileoutput="./.tmp_stats.txt"
+
+echo "Stats piped to file: "$fileoutput
+
+rm $fileoutput
+
+
+
+floatToInt() {
+ printf "%.0f\n" "$@"
+}
+
+do_curl_actuator() {
+ val=$(curl -s localhost:${dfcport}/actuator/metrics/${1} | grep -o -E "\"value\":[0-9.E]+" | awk -F\: '{print $2}')
+ val=$(floatToInt $val)
+ printf "%-20s %+15s\n" $1 $val
+ if [ $heading -eq 1 ]; then
+ echo -n "," $1 >> $fileoutput
+ else
+ echo -n "," $val >> $fileoutput
+ fi
+}
+
+do_curl_status() {
+ curl -s localhost:${dfcport}/status > ./.tmp_curl_res
+ cat ./.tmp_curl_res
+ while read line; do
+ len=${#line}
+ if [ $len -gt 0 ]; then
+ val=${line#*:}
+ id=${line%"$val"}
+ if [ $heading -eq 1 ]; then
+ echo -n "," $id >> $fileoutput
+ else
+ echo -n "," $val >> $fileoutput
+ fi
+ fi
+ done < ./.tmp_curl_res
+
+}
+
+
+while [ true ]; do
+ if [ $heading -eq 1 ]; then
+ echo -n "date" >> $fileoutput
+ else
+ ds=$(date)
+ echo -n $ds >> $fileoutput
+ fi
+ if [ $stat == "all" ] || [ $stat == "jvm" ]; then
+ echo "========= DFC JVM Stats ========="
+ do_curl_actuator jvm.threads.live
+ do_curl_actuator jvm.threads.peak
+ do_curl_actuator process.files.open
+ do_curl_actuator process.files.max
+ do_curl_actuator jvm.memory.used
+ do_curl_actuator jvm.memory.max
+ fi
+
+ if [ $stat == "all" ] || [ $stat == "internal" ]; then
+ echo "========= DFC internal Stats ========="
+ do_curl_status
+ fi
+ echo "" >> $fileoutput
+ heading=0
+ sleep 5
+done \ No newline at end of file