diff options
author | David Timber <dxdt@dev.snart.me> | 2024-11-06 14:33:12 +0100 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2024-11-06 14:33:12 +0100 |
commit | e439d74b7ffaf04b699a96253b03d911cc8a9dec (patch) | |
tree | 00b0118bca8cfef4384019f3256c2c8f3af3476a | |
parent | 12645f4533216d4f0d42708faadc789888640ac2 (diff) |
Add email alert to bitsquat ...
- bitsquat returns exit code 3 upon bitflip
-rw-r--r-- | bitsquat/.gitignore | 3 | ||||
-rw-r--r-- | bitsquat/Makefile | 2 | ||||
-rwxr-xr-x | bitsquat/bitsquat-wired | 18 | ||||
-rw-r--r-- | bitsquat/bitsquat.c | 2 |
4 files changed, 23 insertions, 2 deletions
diff --git a/bitsquat/.gitignore b/bitsquat/.gitignore new file mode 100644 index 0000000..fab703c --- /dev/null +++ b/bitsquat/.gitignore @@ -0,0 +1,3 @@ +/bitsquat +/MAILTO +/bitsquat.out diff --git a/bitsquat/Makefile b/bitsquat/Makefile index aaa47ec..a9bcb6e 100644 --- a/bitsquat/Makefile +++ b/bitsquat/Makefile @@ -7,7 +7,7 @@ CC_CMD = $(CC) $(CC_OPTS) $(CC_OPTS_BT) $(CC_OPTS_EXTRA) all: bitsquat clean: - rm -f bitsquat + rm -f bitsquat bitsquat.*.out bitsquat: bitsquat.c $(CC_CMD) -o bitsquat bitsquat.c diff --git a/bitsquat/bitsquat-wired b/bitsquat/bitsquat-wired new file mode 100755 index 0000000..0ad4bc6 --- /dev/null +++ b/bitsquat/bitsquat-wired @@ -0,0 +1,18 @@ +#!/bin/sh +set -e +. ./MAILTO +set +e + +if [ -z "$MAILTO" ]; then + echo "bitsquat-wired: empty MAILTO env var" >&2 + exit 2 +fi + +OUTFILE=bitsquat.$$.out + +./bitsquat $@ | tee "$OUTFILE" +if [ $? -eq 3 ]; then + mail -s "bitsquat alert" $MAILTO < "$OUTFILE" +else + rm -f "$OUTFILE" +fi diff --git a/bitsquat/bitsquat.c b/bitsquat/bitsquat.c index ea421ba..ed22547 100644 --- a/bitsquat/bitsquat.c +++ b/bitsquat/bitsquat.c @@ -257,7 +257,7 @@ static int do_main (void) { (const uint8_t*)m1, (const uint8_t*)m2, s); - ec = 1; + ec = 3; goto END; } |