commit - 2282d1fffb4634924fb2e60f6318cf7610ba9010
commit + acea22e3a895de55312487c8f075e1f15c85ea25
blob - 4ea9f139259b1559e059a469e3acde8c8e8aeb60
blob + 8941434e5bf40e4c1d7b67344f87d37146925291
--- README.md
+++ README.md
-i = incidents.txt (default)
-p = pastincidents.txt (default)
-o = index.html (default)
- -r = rss file (no default)
+ -r = rss file (no default, optional)
```
For example:
blob - cdacba60ffcb91ea16f68fb1626d02fb5786b5c5
blob + 9453ee84850c1af71d9fb16e04b7404e95b41811
--- incidents.txt
+++ incidents.txt
+202306101055,Incident,Between 00:14 and 00:21 UTC on 2023-06-10 a network outage happened at our upstream provider. Resolved
202306021200,Maintenance,On 2023-06-15 between 22:30-02:30 UTC our upstream provider has scheduled network maintenance
blob - 35deada978a8d9ce656e83ea2e84fd76073c5537
blob + d23e19e772af30785f9e36304d85c5745ef8c8d7
--- uptimeatomic
+++ uptimeatomic
#!/bin/ksh
#
-# Uptime Atomic v20230604
+# Uptime Atomic v2023060401
# https://git.high5.nl/uptimeatomic/
#
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
CONFIGFILE="uptimeatomic.conf"
-WORKDIR=$(dirname -- "$(command -v -- "$0")")
+WORKDIR=$(dirname $0)
usage() {
echo "usage: ${0##*/} [-c checksfile] [-i incidentsfile] [-p pastincidentsfile] [-o htmlfile]" 1>&2
date_rss() {
if [ -n "${1}" ]; then
- date -uj '+%a, %d %b %Y %H:%M:%S %z' ${1}
+ date -ju '+%a, %d %b %Y %H:%M:%S %z' ${1}
else
- date -uj '+%a, %d %b %Y %H:%M:%S %z'
+ date -ju '+%a, %d %b %Y %H:%M:%S %z'
fi
}
date_incident() {
if [ -n "${1}" ]; then
- date -uj '+%F %H:%M %Z' ${1}
+ date -ju '+%F %H:%M %Z' ${1}
else
- date -uj '+%F %H:%M %Z'
+ date -ju '+%F %H:%M %Z'
fi
}
<item>
<title>${_type}</title>
<link>${RSS_URL}/rss.xml</link>
-<guid>${RSS_URL}/rss.xml?$(date -j '+%s' $(echo "${_date}"))</guid>
+<guid>${RSS_URL}/rss.xml?$(date -ju +%s $(echo "${_date}"))</guid>
<pubDate>$(date_rss "${_date}")</pubDate>
<description><![CDATA[ ${_description} ]]></description>
</item>
if [ ${_priority} == "ko" ]; then
echo "${_status}." | mail -r "${TITLE} <${SENDER}>" -s "${_name} DOWN" ${RECIPIENT}
- ${PUSHOVER} -c ${PUSHOVER_CONF} -t "${TITLE}" -m "${_name} DOWN ${_status}." -p 1 >/dev/null 2>&1
+ ${PUSHOVER} -c ${PUSHOVER_CONF} -t "${TITLE}" -m "${_name} DOWN ${_status}" -p 1 >/dev/null 2>&1
touch "${PUSHOVER_STATUS}/${_name}"
fi
if [ ${_priority} == "ok" ]; then
- _seconds=$(expr $(date +%s) - $(stat -r "${PUSHOVER_STATUS}/${_name}" | awk '{print $11}'))
- _downtime=$(date -r${_seconds} -u +%H:%M:%S)
+ _seconds=$(expr $(date -ju +%s) - $(stat -r "${PUSHOVER_STATUS}/${_name}" | awk '{print $11}'))
+ _downtime=$(date -jur ${_seconds} +%H:%M:%S)
echo "${_status} - down for ${_downtime}" | mail -r "${TITLE} <${SENDER}>" -s "${_name} OK" ${RECIPIENT}
${PUSHOVER} -c ${PUSHOVER_CONF} -t "${TITLE}" -m "${_name} OK ${_status} - down for ${_downtime}" >/dev/null 2>&1
fi
;;
ping*)
- ping -${IPv}w "${TIMEOUT}" -c 1 "${_host}" >/dev/null 2>&1
+ ping -${IPv}w "${TIMEOUT}" -c 3 "${_host}" >/dev/null 2>&1
statuscode=$?
if [ "${statuscode}" -ne "${_expectedcode}" ]; then
echo "Host unreachable" > "${_TMP}/ko/${_name}.status"
if [ ${_status_files} == "ko" ]; then
echo "<li>${_name} <span class='small failed'>(${_status})</span><span class='status failed'>Disrupted</span></li>" >> ${_HTMLFILE}
if [ ! -e "${PUSHOVER_STATUS}/${_name}" ]; then
- notify "${_name}" "${status}" "${_status_files}"
+ notify "${_name}" "${_status}" "${_status_files}"
fi
fi
if [ ${_status_files} == "maint" ]; then
}
cd ${WORKDIR}
-if [ -e "${CONFIGFILE}" ]; then
+if [ -s "${CONFIGFILE}" ]; then
. ${WORKDIR}/${CONFIGFILE}
else
- echo "Configfile ${WORKDIR}/${CONFIGFILE} doesn't exist."
+ echo "Config ${WORKDIR}/${CONFIGFILE} doesn't exist."
exit
fi
i) INCIDENTSFILE=${OPTARG};;
p) PASTINCIDENTSFILE=${OPTARG};;
o) HTMLFILE=${OPTARG};;
- r) RSS_FILE=${OPTARG};;
+ r) RSSFILE=${OPTARG};;
h) usage;;
*) usage;;
esac
_TMP="$(mktemp -d)"
mkdir -p "${_TMP}/ok" "${_TMP}/ko" "${_TMP}/maint" || exit 1
_HTMLFILE="${_TMP}/${HTMLFILE}"
-[[ -n "${RSS_FILE}" ]] && _RSSFILE="${_TMP}/${RSS_FILE}"
+[[ -n "${RSSFILE}" ]] && _RSSFILE="${_TMP}/${RSSFILE}"
parse_file "${CHECKFILE}"
process_status "ok"
echo "</ul>" >> ${_HTMLFILE}
-echo "<p class=small>Last check: $(date -u '+%FT%T %Z')</p>" >> ${_HTMLFILE}
+echo "<p class=small>Last check: $(date -ju '+%FT%T %Z')</p>" >> ${_HTMLFILE}
if [ -s "${PASTINCIDENTSFILE}" ]; then
echo '<h3>Past Incidents / Maintenance</h3>' >> ${_HTMLFILE}
<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 "${_RSSFILE}" ]] && echo " - <a href='${RSS_URL}/${RSS_FILE}'>RSS</a>" >> ${_HTMLFILE}
+[[ -n "${_RSSFILE}" ]] && echo " - <a href='${RSS_URL}/${RSSFILE}'>RSS</a>" >> ${_HTMLFILE}
cat << EOF >> ${_HTMLFILE}
</p>
</div>
EOF
fi
-if [[ -f "${HTMLDIR}/${RSS_FILE}" ]]; then
- _diff=$(diff "${_RSSFILE}" "${HTMLDIR}/${RSS_FILE}" | wc -l)
+if [[ -f "${HTMLDIR}/${RSSFILE}" ]]; then
+ _diff=$(diff "${_RSSFILE}" "${HTMLDIR}/${RSSFILE}" | wc -l)
if [ "${_diff}" -ne "4" ]; then
- cp ${_RSSFILE} ${HTMLDIR}/${RSS_FILE}
+ cp ${_RSSFILE} ${HTMLDIR}/${RSSFILE}
fi
-elif [ -n "${RSS_FILE}" ]; then
- cp ${_RSSFILE} ${HTMLDIR}/${RSS_FILE}
+elif [ -n "${RSSFILE}" ]; then
+ cp ${_RSSFILE} ${HTMLDIR}/${RSSFILE}
fi
cp ${_HTMLFILE} ${HTMLDIR}/${HTMLFILE}