Use comma-separated value text file

CSV is a well-supported standard and makes things more
predictable/easier to see where things go.
This commit is contained in:
Alex Povel 2021-03-29 17:25:25 +02:00
parent 1de60a20d7
commit 6ec20342f0
4 changed files with 7 additions and 7 deletions

View file

@ -20,7 +20,7 @@ An example site is available [here](https://lab.bdro.fr/tinystatus/).
To install tinystatus:
* Clone the repository and go to the created directory
* Edit the checks file `checks.list`
* Edit the checks file `checks.csv`
* To add incidents or maintenance, edit `incidents.list`
* Generate status page `./tinystatus > index.html`
* Serve the page with your favorite web server

4
checks.csv Normal file
View file

@ -0,0 +1,4 @@
http, 200, Google Website, https://google.com
http, 404, Google 404, https://google.com/dummy
ping, 0, Google ping, 8.8.8.8
port, 0, Google DNS, 8.8.8.8:53
1 http 200 Google Website https://google.com
2 http 404 Google 404 https://google.com/dummy
3 ping 0 Google ping 8.8.8.8
4 port 0 Google DNS 8.8.8.8:53

View file

@ -1,4 +0,0 @@
http | 200 | Google website | https://google.com
http | 404 | Google 404 | https://google.com/dummy
ping | 0 | Google ping | 8.8.8.8
port | 0 | Google dns | 8.8.8.8:53

View file

@ -3,7 +3,7 @@
title=tinystatus
timeout=10
tmp="$(mktemp -d)"
checkfile="${1:-checks.list}"
checkfile="${1:-checks.csv}"
incidentsfile="${2:-incidents.list}"
useragent="User-Agent: Mozilla/5.0 (X11; Linux x86_64; Debian) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"
@ -15,7 +15,7 @@ command_exists(){
}
get_element(){
echo "${2}" | awk -v col="${1}" -F'|' '{gsub(/^[ \t]+|[ \t]+$/, "", $col); print $col}'
echo "${2}" | awk -v col="${1}" -F',' '{gsub(/^[ \t]+|[ \t]+$/, "", $col); print $col}'
}
check(){