Add error code on outage

This commit is contained in:
BDR 2021-03-30 17:42:11 +02:00
parent 0a48aaab08
commit 3d820a67cb

View file

@ -5,6 +5,7 @@ timeout=10
tmp="$(mktemp -d)" tmp="$(mktemp -d)"
checkfile="${1:-checks.csv}" checkfile="${1:-checks.csv}"
incidentsfile="${2:-incidents.txt}" 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" 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(){ command_exists(){
@ -87,10 +88,8 @@ EOF
outagenb=$(find ${tmp}/ko -mindepth 1 | grep -c 'status$') outagenb=$(find ${tmp}/ko -mindepth 1 | grep -c 'status$')
if [ ${outagenb} -ne 0 ]; then if [ ${outagenb} -ne 0 ]; then
echo "<ul><li class='panel failed-bg'>${outagenb} Outage(s)</li></ul>" echo "<ul><li class='panel failed-bg'>${outagenb} Outage(s)</li></ul>"
exitcode=1
else else
echo "<ul><li class='panel success-bg'>All Systems Operational</li></ul>" echo "<ul><li class='panel success-bg'>All Systems Operational</li></ul>"
exitcode=0
fi fi
cat << EOF cat << EOF
<h1>Services</h1> <h1>Services</h1>
@ -123,7 +122,9 @@ cat <<EOF
</div> </div>
</body></html> </body></html>
EOF EOF
rm -r "${tmp}" 2>/dev/null
# Allow the script execution itself to signal success, e.g. for use in healthchecks rm -r "${tmp}" 2>/dev/null
exit ${exitcode} if [ "${failonoutage}" = true ]; then
exit "${outagenb}"
fi