From b6da99b4ae40952dc33956266356d46e4104bb22 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 14 May 2022 10:16:02 +0200 Subject: [PATCH] cleanup health check script --- recorder-health.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/recorder-health.sh b/recorder-health.sh index 02e65ef..9015488 100644 --- a/recorder-health.sh +++ b/recorder-health.sh @@ -1,30 +1,29 @@ #!/bin/sh -addr=`hostname` -port=8083 +ADDR=`hostname` +PORT=8083 -epoch=$(date +%s) +EPOCH=$(date +%s) -location=$(cat < /dev/null +curl -sSL --data "${LOCATION}" "http://${ADDR}:${PORT}/pub?u=ping&d=ping" > /dev/null # obtain tst of ping/ping's last location -ret_epoch=$(curl -sSL http://${addr}:${port}/api/0/last --data "user=ping&device=ping" | - env jq -r '.[0].tst' ) +RET_EPOCH=$(curl -sSL http://${ADDR}:${PORT}/api/0/last --data "user=ping&device=ping" | env jq -r '.[0].tst' ) -if [ $epoch -ne $ret_epoch ]; then - echo PANIC $epoch $ret_epoch +if [ ${EPOCH} -ne ${RET_EPOCH} ]; then + echo PANIC ${EPOCH} ${RET_EPOCH} exit 1 else echo OK