From 3d820a67cb4926d3bc33bee0e75de67f8ec40a82 Mon Sep 17 00:00:00 2001 From: BDR Date: Tue, 30 Mar 2021 17:42:11 +0200 Subject: [PATCH] Add error code on outage --- tinystatus | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tinystatus b/tinystatus index 454520c..1ad33f6 100755 --- a/tinystatus +++ b/tinystatus @@ -5,6 +5,7 @@ timeout=10 tmp="$(mktemp -d)" checkfile="${1:-checks.csv}" incidentsfile="${2:-incidents.txt}" +failonoutage=false useragent="User-Agent: Mozilla/5.0 (X11; Linux x86_64; Debian) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" command_exists(){ @@ -87,10 +88,8 @@ EOF outagenb=$(find ${tmp}/ko -mindepth 1 | grep -c 'status$') if [ ${outagenb} -ne 0 ]; then echo "" - exitcode=1 else echo "" - exitcode=0 fi cat << EOF

Services

@@ -123,7 +122,9 @@ cat < EOF -rm -r "${tmp}" 2>/dev/null -# Allow the script execution itself to signal success, e.g. for use in healthchecks -exit ${exitcode} +rm -r "${tmp}" 2>/dev/null +if [ "${failonoutage}" = true ]; then + exit "${outagenb}" +fi +