commit 9ce8d96b3b3fbc117c81e9a9ecd5894f0f98dbe9 from: mischa date: Sat Oct 21 13:03:21 2023 UTC add logic to move pastincidents to seperate page commit - e3f8b0efda531cb6c82163158c1578aa0a26d82b commit + 9ce8d96b3b3fbc117c81e9a9ecd5894f0f98dbe9 blob - 7e7ed89e3ceb238a0d39ff061b96cb5a847fbebc blob + 2e168eb2d254db94c6439947f6f5a8909b1bf0ea --- uptimeatomic +++ uptimeatomic @@ -1,7 +1,7 @@ #!/bin/ksh # -# Uptime Atomic v2023060401 -# https://git.high5.nl/uptimeatomic/ +# Uptime Atomic v20231021 +# https://code.high5.nl/High5/uptimeatomic # export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin CONFIGFILE="uptimeatomic.conf" @@ -35,9 +35,14 @@ incidents() { _date=${1} _type=${2} _description=${3} + _file=${4} [[ ${_type} == "Incident" ]] && color="failed" [[ ${_type} == "Maintenance" ]] && color="maint" - echo "

$(date_incident ${_date}) - ${_type}
${_description}

" >> ${_HTMLFILE} + if [ ${_file} == "${PASTINCIDENTSFILE}" ]; then + echo "

$(date_incident ${_date}) - ${_type}
${_description}

" >> ${_PASTHTMLFILE} + else + echo "

$(date_incident ${_date}) - ${_type}
${_description}

" >> ${_HTMLFILE} + fi if [ -n "${_RSSFILE}" ]; then cat << EOF >> ${_RSSFILE} @@ -154,7 +159,7 @@ parse_file() { if [[ ${_file} == *".csv" ]]; then check "${_col1}" "${_col2}" "${_col3}" "${_col4}" "${_col5}" & else - incidents "${_col1}" "${_col2}" "${_col3}" + incidents "${_col1}" "${_col2}" "${_col3}" "${_file}" fi done < "${_file}" wait @@ -188,6 +193,7 @@ fi _TMP="$(mktemp -d)" mkdir -p "${_TMP}/ok" "${_TMP}/ko" "${_TMP}/maint" || exit 1 _HTMLFILE="${_TMP}/${HTMLFILE}" +_PASTHTMLFILE="${_TMP}/${PASTHTMLFILE}" [[ -n "${RSSFILE}" ]] && _RSSFILE="${_TMP}/${RSSFILE}" parse_file "${CHECKFILE}" @@ -195,7 +201,7 @@ parse_file "${CHECKFILE}" # # HTML # -cat << EOF > ${_HTMLFILE} +cat << EOF | tee ${_HTMLFILE} | tee ${_PASTHTMLFILE} >/dev/null @@ -276,19 +282,20 @@ echo "" >> ${_HTMLFILE} echo "

Last check: $(date -ju '+%FT%T %Z')

" >> ${_HTMLFILE} if [ -s "${PASTINCIDENTSFILE}" ]; then - echo '

Past Incidents / Maintenance

' >> ${_HTMLFILE} + echo '

Past Incidents / Maintenance

' >> ${_PASTHTMLFILE} parse_file "${PASTINCIDENTSFILE}" fi # # END HTML # -cat << EOF >> ${_HTMLFILE} +cat << EOF | tee -a ${_HTMLFILE} | tee -a ${_PASTHTMLFILE} >/dev/null

Uptime Atomic loosely based on Tinystatus EOF +[[ -n "${_PASTHTMLFILE}" ]] && echo " - Past Incidents" >> ${_HTMLFILE} [[ -n "${_RSSFILE}" ]] && echo " - RSS" >> ${_HTMLFILE} -cat << EOF >> ${_HTMLFILE} +cat << EOF | tee -a ${_HTMLFILE} | tee -a ${_PASTHTMLFILE} >/dev/null

@@ -315,4 +322,5 @@ elif [ -n "${RSSFILE}" ]; then fi cp ${_HTMLFILE} ${HTMLDIR}/${HTMLFILE} +cp ${_PASTHTMLFILE} ${HTMLDIR}/${PASTHTMLFILE} rm -r "${_TMP}" 2>/dev/null