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
78 OK=0 # Flag for DFC response (0==no response, 1==reponse ok and logging can start)
81 if [ $OK -eq 0 ]; then
82 test=$(curl -s localhost:${dfcport}/status)
83 if [ -z "$test" ] && [ $heading -eq 1 ]; then
84 echo "No response from dfc on port: ${dfcport}. Retrying..."
86 echo "Response from dfc on port: ${dfcport}. Starts logging."
90 if [ $OK -eq 1 ]; then
91 if [ $heading -eq 1 ]; then
92 echo -n "date" >> $fileoutput
95 echo -n $ds >> $fileoutput
97 if [ $stat == "all" ] || [ $stat == "jvm" ]; then
98 echo "========= DFC JVM Stats ========="
99 do_curl_actuator jvm.threads.live
100 do_curl_actuator jvm.threads.peak
101 do_curl_actuator process.files.open
102 do_curl_actuator process.files.max
103 do_curl_actuator jvm.memory.used
104 do_curl_actuator jvm.memory.max
107 if [ $stat == "all" ] || [ $stat == "internal" ]; then
108 echo "========= DFC internal Stats ========="
111 echo "" >> $fileoutput