From d458e344efa76a165d9141e8a479706b87ee25b3 Mon Sep 17 00:00:00 2001 From: mischa Date: Tue, 30 May 2023 20:06:53 +0000 Subject: [PATCH] add option for past incidents at the bottom of the page --- pastincidents.txt | 0 tinystatus | 26 ++++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 pastincidents.txt diff --git a/pastincidents.txt b/pastincidents.txt new file mode 100644 index 0000000..e69de29 diff --git a/tinystatus b/tinystatus index 1b8fb58..43f056e 100755 --- a/tinystatus +++ b/tinystatus @@ -7,10 +7,12 @@ HEADER="Global Status" HTMLDIR="/var/www/htdocs/default" HTMLFILE="index.html" INCIDENTSFILE="incidents.txt" +PASTINCIDENTSFILE="pastincidents.txt" PUSHOVER="/home/mischa/bin/pushover.pl" PUSHOVER_CONF="/home/mischa/_pushover.conf" PUSHOVER_STATUS="status" RECIPIENT="alerts@high5.nl" +REFRESH=60 SENDER="tinystatus@high5.nl" TIMEOUT=10 TITLE="Tiny Status" @@ -18,7 +20,7 @@ USERAGENT="User-Agent: Mozilla/5.0 (OpenBSD; Intel OpenBSD 7.4; rv:109.0) Gecko/ WORKDIR=/home/mischa/tinystatus usage() { - echo "usage: ${0##*/} [-c checksfile] [-i incidentsfile] [-o htmlfile]" 1>&2 + echo "usage: ${0##*/} [-c checksfile] [-i incidentsfile] [-p pastincidentsfile] [-o htmlfile]" 1>&2 exit } @@ -94,6 +96,7 @@ while getopts c:i:o:h arg; do case ${arg} in c) CHECKFILE=${OPTARG};; i) INCIDENTSFILE=${OPTARG};; + p) PASTINCIDENTSFILE=${OPTARG};; o) HTMLFILE=${OPTARG};; h) usage;; *) usage;; @@ -120,7 +123,14 @@ done < "${CHECKFILE}" wait cat << EOF >> ${_htmlfile} -${TITLE} + +

${HEADER}

@@ -189,8 +200,15 @@ done cat << EOF >> ${_htmlfile}

Last check: $(date +%FT%T%z) Tinystatus loosely based on Tinystatus

+EOF +if [ -s "${PASTINCIDENTSFILE}" ]; then + echo '

Past Incidents

' >> ${_htmlfile} + sed 's|^\(.*\)$|

\1

|' "${PASTINCIDENTSFILE}" >> ${_htmlfile} +fi +cat << EOF >> ${_htmlfile}
- + + EOF cp ${_htmlfile} ${HTMLDIR}/${HTMLFILE}