This repository has been archived on 2023-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
awesome-scripts/healthcheck.sh

25 lines
499 B
Bash
Raw Normal View History

2020-05-20 23:57:45 +00:00
#!/bin/bash
if [[ "$#" -lt 2 ]]; then
echo "Usage: $0 <uuid> <command>"
exit 1;
fi
UUID=$1
ARGS=("$@")
COMMANDS=("${ARGS[@]:1}")
echo -n "PING: "
curl -fsS --retry 3 "https://health.sp-codes.de/ping/$UUID/start"
echo
echo "RUN ${COMMANDS[@]}:"
LOG=$("${COMMANDS[@]}" 2>&1)
CODE=$?
echo "$LOG"
echo -n "PING: "
# append the last 10 kb
echo "$LOG" | tail --bytes 10240 | curl -fsS --retry 3 --data-binary @- "https://health.sp-codes.de/ping/$UUID$([[ ${CODE} -ne 0 ]] && echo -n /fail)"
echo