summaryrefslogtreecommitdiff
path: root/tsp
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2017-04-26 11:48:37 (GMT)
committerAleksander Mistewicz <a.mistewicz@samsung.com>2017-08-08 08:18:08 (GMT)
commit6246e243fb1a67d378b9d311778b76369202a6e8 (patch)
tree9c502bbf25eed7402b61ff65fb779dead5e5e6bf /tsp
parente7b8edff5a2a5231cfacfda973f4f7ef280fb088 (diff)
downloadmajor-6246e243fb1a67d378b9d311778b76369202a6e8.zip
major-6246e243fb1a67d378b9d311778b76369202a6e8.tar.gz
major-6246e243fb1a67d378b9d311778b76369202a6e8.tar.bz2
Report SDB server state to Prometheusrefs/changes/25/130925/3
Change-Id: Ied4f1a12ae11c0486dbeb330de0988541116d0c1
Diffstat (limited to 'tsp')
-rwxr-xr-xtsp/common.sh17
-rwxr-xr-xtsp/jobs/watch_sdb.sh11
2 files changed, 24 insertions, 4 deletions
diff --git a/tsp/common.sh b/tsp/common.sh
index 69f20fa..43ddf39 100755
--- a/tsp/common.sh
+++ b/tsp/common.sh
@@ -46,6 +46,9 @@ WS_PUBLISH="${WS}/publish"
SNAPSHOT_WS_DOWNLOAD="${WS_DOWNLOAD}/snapshot"
SNAPSHOT_WS_DOWNLOAD_NEW="${WS_DOWNLOAD}/new_snapshot"
+PROM_DIR="${WS}/prom"
+
+test -d "${PROM_DIR}" || mkdir -p "${PROM_DIR}"
test -d "${WS_PUBLISH}" || mkdir -p "${WS_PUBLISH}"
DBNAME="results.db3"
@@ -79,6 +82,20 @@ init_db() {
test -f "${DBPATH}" || init_db
+post_prom() {
+ NAME="$1"
+ VALUE="$2"
+ HELP="$3"
+ test -n "$NAME" || die "Missing argument: name"
+ test -n "$VALUE" || die "Missing argument: value"
+ {
+ test -z "$HELP" || echo "# HELP $NAME $HELP"
+ echo "# TYPE $NAME gauge"
+ echo "$NAME $VALUE"
+ } > "$PROM_DIR/temp.$$"
+ mv "$PROM_DIR/temp.$$" "$PROM_DIR/$NAME.prom"
+}
+
tsrun_target() {
test -n "$1" || die "Missing argument: target"
TMPDIR="/tmp/tl-runner-$1"
diff --git a/tsp/jobs/watch_sdb.sh b/tsp/jobs/watch_sdb.sh
index 27eb814..4546f9a 100755
--- a/tsp/jobs/watch_sdb.sh
+++ b/tsp/jobs/watch_sdb.sh
@@ -16,6 +16,10 @@
# Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
+export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.."
+
+. "${TSP_DIR}/common.sh"
+
# make sure the server is running
timeout 120 sdb start-server
@@ -23,10 +27,9 @@ timeout 120 sdb start-server
SDB="$(timeout 120 sdb devices)"
SDB_RET="$?"
-if [ "${SDB_RET}" -eq 0 ]; then
- echo $(date) ok >> /tmp/sdb.log
-else
- echo $(date) restart >> /tmp/sdb.log
+if [ "${SDB_RET}" -ne 0 ]; then
killall sdb
sdb start-server
fi
+
+post_prom "sdb_status" "$SDB_RET" "Return value of sdb devices"