From e439d74b7ffaf04b699a96253b03d911cc8a9dec Mon Sep 17 00:00:00 2001 From: David Timber Date: Wed, 6 Nov 2024 14:33:12 +0100 Subject: Add email alert to bitsquat ... - bitsquat returns exit code 3 upon bitflip --- bitsquat/.gitignore | 3 +++ bitsquat/Makefile | 2 +- bitsquat/bitsquat-wired | 18 ++++++++++++++++++ bitsquat/bitsquat.c | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 bitsquat/.gitignore create mode 100755 bitsquat/bitsquat-wired 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; } -- cgit