commit - e3f8b0efda531cb6c82163158c1578aa0a26d82b
commit + 9ce8d96b3b3fbc117c81e9a9ecd5894f0f98dbe9
blob - 7e7ed89e3ceb238a0d39ff061b96cb5a847fbebc
blob + 2e168eb2d254db94c6439947f6f5a8909b1bf0ea
--- uptimeatomic
+++ uptimeatomic
#!/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"
_date=${1}
_type=${2}
_description=${3}
+ _file=${4}
[[ ${_type} == "Incident" ]] && color="failed"
[[ ${_type} == "Maintenance" ]] && color="maint"
- echo "<p>$(date_incident ${_date}) - <b class='${color}'>${_type}</b><br />${_description}</p>" >> ${_HTMLFILE}
+ if [ ${_file} == "${PASTINCIDENTSFILE}" ]; then
+ echo "<p>$(date_incident ${_date}) - <b class='${color}'>${_type}</b><br />${_description}</p>" >> ${_PASTHTMLFILE}
+ else
+ echo "<p>$(date_incident ${_date}) - <b class='${color}'>${_type}</b><br />${_description}</p>" >> ${_HTMLFILE}
+ fi
if [ -n "${_RSSFILE}" ]; then
cat << EOF >> ${_RSSFILE}
<item>
if [[ ${_file} == *".csv" ]]; then
check "${_col1}" "${_col2}" "${_col3}" "${_col4}" "${_col5}" &
else
- incidents "${_col1}" "${_col2}" "${_col3}"
+ incidents "${_col1}" "${_col2}" "${_col3}" "${_file}"
fi
done < "${_file}"
wait
_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}"
#
# HTML
#
-cat << EOF > ${_HTMLFILE}
+cat << EOF | tee ${_HTMLFILE} | tee ${_PASTHTMLFILE} >/dev/null
<!DOCTYPE html>
<html lang="en">
<head>
echo "<p class=small>Last check: $(date -ju '+%FT%T %Z')</p>" >> ${_HTMLFILE}
if [ -s "${PASTINCIDENTSFILE}" ]; then
- echo '<h3>Past Incidents / Maintenance</h3>' >> ${_HTMLFILE}
+ echo '<h2>Past Incidents / Maintenance</h2>' >> ${_PASTHTMLFILE}
parse_file "${PASTINCIDENTSFILE}"
fi
#
# END HTML
#
-cat << EOF >> ${_HTMLFILE}
+cat << EOF | tee -a ${_HTMLFILE} | tee -a ${_PASTHTMLFILE} >/dev/null
<p class=small>
<a href="https://git.high5.nl/uptimeatomic/">Uptime Atomic</a> loosely based on <a href="https://github.com/bderenzo/tinystatus">Tinystatus</a>
EOF
+[[ -n "${_PASTHTMLFILE}" ]] && echo " - <a href='${PASTHTMLFILE}'>Past Incidents</a>" >> ${_HTMLFILE}
[[ -n "${_RSSFILE}" ]] && echo " - <a href='${RSS_URL}/${RSSFILE}'>RSS</a>" >> ${_HTMLFILE}
-cat << EOF >> ${_HTMLFILE}
+cat << EOF | tee -a ${_HTMLFILE} | tee -a ${_PASTHTMLFILE} >/dev/null
</p>
</div>
</body>
fi
cp ${_HTMLFILE} ${HTMLDIR}/${HTMLFILE}
+cp ${_PASTHTMLFILE} ${HTMLDIR}/${PASTHTMLFILE}
rm -r "${_TMP}" 2>/dev/null