3 # Script to print internal dfc stats every 5 sec to screen and file
4 # Default port is 8100 for DFC
5 # Useage: ./dfc-internal-stats.sh all|internal|jvm [<dfc-port-number>]
8 echo "Useage: ./dfc-internal-stats.sh all|internal|jvm [<dfc-port-number>]"
14 elif [ $# -eq 1 ]; then
17 elif [ $# -eq 2 ]; then
27 if [ $stat == "all" ]; then
28 echo "Printing stats for both JVM and DFC using port "$dfcport
29 elif [ $stat == "internal" ]; then
30 echo "Printing stats for DFC using port "$dfcport
31 elif [ $stat == "jvm" ]; then
32 echo "Printing stats for JVM using port "$dfcport
37 fileoutput="./.tmp_stats.txt"
39 echo "Stats piped to file: "$fileoutput
50 val=$(curl -s localhost:${dfcport}/actuator/metrics/${1} | grep -o -E "\"value\":[0-9.E]+" | awk -F\: '{print $2}')
51 val=$(floatToInt $val)
52 printf "%-20s %+15s\n" $1 $val
53 if [ $heading -eq 1 ]; then
54 echo -n "," $1 >> $fileoutput
56 echo -n "," $val >> $fileoutput
61 curl -s localhost:${dfcport}/status > ./.tmp_curl_res
65 if [ $len -gt 0 ]; then
68 if [ $heading -eq 1 ]; then
69 echo -n "," $id >> $fileoutput
71 echo -n "," $val >> $fileoutput
74 done < ./.tmp_curl_res
80 if [ $heading -eq 1 ]; then
81 echo -n "date" >> $fileoutput
84 echo -n $ds >> $fileoutput
86 if [ $stat == "all" ] || [ $stat == "jvm" ]; then
87 echo "========= DFC JVM Stats ========="
88 do_curl_actuator jvm.threads.live
89 do_curl_actuator jvm.threads.peak
90 do_curl_actuator process.files.open
91 do_curl_actuator process.files.max
92 do_curl_actuator jvm.memory.used
93 do_curl_actuator jvm.memory.max
96 if [ $stat == "all" ] || [ $stat == "internal" ]; then
97 echo "========= DFC internal Stats ========="
100 echo "" >> $fileoutput