From 11bddbb4faabd43e5b1bfc7d3c4c827b918be89d Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Mon, 29 Mar 2021 17:25:25 +0200 Subject: [PATCH] Use comma-separated value text file CSV is a well-supported standard and makes things more predictable/easier to see where things go. --- README.md | 2 +- checks.csv | 6 ++++++ checks.list | 6 ------ tinystatus | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 checks.csv delete mode 100644 checks.list diff --git a/README.md b/README.md index 0208e72..1bb13b3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/checks.csv b/checks.csv new file mode 100644 index 0000000..176f1b6 --- /dev/null +++ b/checks.csv @@ -0,0 +1,6 @@ +http, 200, Google Website, https://google.com +http, 404, Google 404, https://google.com/dummy +http4, 200, Google website (IPv4), https://google.com +http6, 200, Google website (IPv6), https://google.com +ping, 0, Google ping, 8.8.8.8 +port, 0, Google DNS, 8.8.8.8 53 diff --git a/checks.list b/checks.list deleted file mode 100644 index 7375b0b..0000000 --- a/checks.list +++ /dev/null @@ -1,6 +0,0 @@ -http | 200 | Google website | https://google.com -http4 | 200 | Google website (IPv4) | https://google.com -http6 | 200 | Google website (IPv6) | 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 diff --git a/tinystatus b/tinystatus index f2e7e34..ea0b35b 100755 --- a/tinystatus +++ b/tinystatus @@ -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(){