From 6ec20342f00374c9f4baaa2b5337932c36d5eba0 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 | 4 ++++ checks.list | 4 ---- tinystatus | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 checks.csv delete mode 100644 checks.list diff --git a/README.md b/README.md index 5685834..51ba1f1 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..76f0437 --- /dev/null +++ b/checks.csv @@ -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 diff --git a/checks.list b/checks.list deleted file mode 100644 index 07a1543..0000000 --- a/checks.list +++ /dev/null @@ -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 diff --git a/tinystatus b/tinystatus index ded7797..89f0032 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(){