move config to uptimeatomic.conf

This commit is contained in:
mischa 2023-06-03 16:04:03 +00:00
parent dc7ffa7fa4
commit d8d124d664
4 changed files with 38 additions and 31 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
high5*
obsdams*
uptimeatomic.conf

View File

@ -23,7 +23,7 @@ An example site is available [here](https://ops.lowfive.nl/)
To install uptimeatomic:
* Clone the repository and go to the created directory
* Edit `uptimeatomic` variables to your liking
* Edit `uptimeatomic.conf` variables to your liking
* Edit the checks file `checks.csv`
* To add incidents or maintenance, edit `incidents.txt`
* To add past incidents or maintenance, edit `pastincidents.txt`

View File

@ -5,25 +5,8 @@
#
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
CHECKFILE="checks.csv"
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
RSS_DESCRIPTION="Incidents and Maintenance Updates"
RSS_FILE=""
RSS_URL="https://ops.lowfive.nl"
SENDER="uptimeatomic@high5.nl"
TIMEOUT=10
TITLE="Uptime Atomic - OpenBSD Amsterdam"
USERAGENT="User-Agent: Mozilla/5.0 (OpenBSD; Intel OpenBSD 7.4; rv:109.0) Gecko/20100101 Firefox/113.0"
WORKDIR=/home/mischa/uptimeatomic
CONFIGFILE="uptimeatomic.conf"
WORKDIR="/home/mischa/uptimeatomic"
usage() {
echo "usage: ${0##*/} [-c checksfile] [-i incidentsfile] [-p pastincidentsfile] [-o htmlfile]" 1>&2
@ -135,27 +118,27 @@ check() {
esac
}
process_health() {
_health=${1}
process_status() {
_status_files=${1}
ls ${_TMP}/${_health}/*.status 2>/dev/null | sort -V | while read file; do
ls ${_TMP}/${_status_files}/*.status 2>/dev/null | sort -V | while read file; do
[ -e "${file}" ] || continue
_name="$(basename "${file%.status}")"
_status="$(cat "${file}")"
if [ ${_health} == "ko" ]; then
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}" "${_health}"
notify "${_name}" "${status}" "${_status_files}"
fi
fi
if [ ${_health} == "maint" ]; then
if [ ${_status_files} == "maint" ]; then
echo "<li>${_name} <span class='status maint'>Maintenance</span></li>" >> ${_HTMLFILE}
fi
if [ ${_health} == "ok" ]; then
if [ ${_status_files} == "ok" ]; then
echo "<li>${_name} <span class='status success'>Operational</span></li>" >> ${_HTMLFILE}
if [ -e "${PUSHOVER_STATUS}/${_name}" ]; then
notify "${_name}" "${_status}" "${_health}"
notify "${_name}" "${_status}" "${_status_files}"
fi
fi
done
@ -191,11 +174,16 @@ while getopts c:i:o:r:h arg; do
done
cd ${WORKDIR}
if [ ! -e "${CONFIGFILE}" ]; then
echo "Configfile ${WORKDIR}/${CONFIGFILE} doesn't exist."
exit
fi
if [ ! -e "${CHECKFILE}" ]; then
echo "Checkfile ${WORKDIR}/${CHECKFILE} doesn't exist."
exit
fi
. ${WORKDIR}/${CONFIGFILE}
_TMP="$(mktemp -d)"
mkdir -p "${_TMP}/ok" "${_TMP}/ko" "${_TMP}/maint" || exit 1
_HTMLFILE="${_TMP}/${HTMLFILE}"
@ -271,9 +259,9 @@ fi
echo "<h1>Services</h1>" >> ${_HTMLFILE}
echo "<ul>" >> ${_HTMLFILE}
process_health "ko"
process_health "maint"
process_health "ok"
process_status "ko"
process_status "maint"
process_status "ok"
echo "</ul>" >> ${_HTMLFILE}
echo "<p class=small>Last check: $(date -u '+%FT%T %Z')</p>" >> ${_HTMLFILE}

18
uptimeatomic.conf-example Normal file
View File

@ -0,0 +1,18 @@
CHECKFILE="checks.csv"
HEADER="Global Status"
HTMLDIR="/var/www/htdocs/default"
HTMLFILE="index.html"
INCIDENTSFILE="incidents.txt"
PASTINCIDENTSFILE="pastincidents.txt"
PUSHOVER="/home/root/bin/pushover.pl"
PUSHOVER_CONF="/home/root/_pushover.conf"
PUSHOVER_STATUS="status"
RECIPIENT="alerts@example.com"
REFRESH=60
RSS_DESCRIPTION="Incidents and Maintenance Updates"
RSS_FILE=""
RSS_URL="https://ops.example.com"
SENDER="uptimeatomic@example.com"
TIMEOUT=10
TITLE="Uptime Atomic"
USERAGENT="User-Agent: Mozilla/5.0 (OpenBSD; Intel OpenBSD 7.4; rv:109.0) Gecko/20100101 Firefox/113.0"