Commit Diff


commit - dc7ffa7fa4fcfc6c9678d5d0f9ba41af92deb0d6
commit + d8d124d6640f988bcdc72a58c8eba1c9d9c358bf
blob - f0f68a9c44f5ae2c9f3dda95b6ecde4000c858de
blob + c5d1876395e986052c242714d2b041ef342e7c70
--- .gitignore
+++ .gitignore
@@ -1,2 +1,3 @@
 high5*
 obsdams*
+uptimeatomic.conf
blob - bf46d1a2dbdc4447b04aa26aaeff9b28df15d5a4
blob + ae622cad34db2f2b06091a09d0aacb0e8534c8e6
--- README.md
+++ README.md
@@ -23,7 +23,7 @@ An example site is available [here](https://ops.lowfiv
 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`
blob - c835242ed201f1d2022e1bb42c76173948ef7f71
blob + df4fbf449a7eb5cacbc67a7bbc6080b60f4178d6
--- uptimeatomic
+++ uptimeatomic
@@ -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}
blob - /dev/null
blob + 799fc8b096255ef04c67b32477055b2b22931139 (mode 644)
--- /dev/null
+++ uptimeatomic.conf-example
@@ -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"