Log running time to Prometheus 09/181809/1
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 13 Jun 2017 10:20:15 +0000 (12:20 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 8 Aug 2017 08:18:08 +0000 (10:18 +0200)
Change-Id: I23d3f8ad05d22b1578457ecca29a6e677b65e095

tsp/watchers/watch_target_queues.sh

index 5380484..2d4df31 100755 (executable)
@@ -19,10 +19,21 @@ export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
 
 . "${TSP_DIR}/common.sh"
 
+TIMES_NAME="tsrun_time"
+TIMES="$(mktemp)"
+{
+    echo "# HELP $TIMES_NAME Execution time of the most recent command"
+    echo "# TYPE $TIMES_NAME gauge"
+} > "$TIMES"
+
 for ltarget in $TARGET_LIST
 do
     target="${ltarget#*-}"
     COUNT="$(tsrun_target "${target}" | grep queued | wc -l)"
     # Report queue length
     post_prom "tsrun_queued_${target}" "$COUNT" "Length of ${target} queue"
+    TIME="$(tsrun_target "${target}" -i | grep -o "[0-9]\+\.[0-9]\+")"
+    echo "${TIMES_NAME}{target=\"${ltarget}\"} $TIME" >> "$TIMES" #FIXME use real target instead of l-target
 done
+
+mv "$TIMES" "$PROM_DIR/tsrun_times.prom"