From 69e5b7dc2e8093d2cfb10a7cf4618b940d9f5437 Mon Sep 17 00:00:00 2001 From: Aleksander Mistewicz Date: Tue, 13 Jun 2017 12:20:15 +0200 Subject: [PATCH] Log running time to Prometheus Change-Id: I23d3f8ad05d22b1578457ecca29a6e677b65e095 --- tsp/watchers/watch_target_queues.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tsp/watchers/watch_target_queues.sh b/tsp/watchers/watch_target_queues.sh index 5380484..2d4df31 100755 --- a/tsp/watchers/watch_target_queues.sh +++ b/tsp/watchers/watch_target_queues.sh @@ -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" -- 2.7.4