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"
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"
# 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
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"