From ab5fd49157e69ef8ffc05b754f7d8f5815836403 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Thu, 23 Nov 2023 21:15:31 +0100 Subject: [PATCH] Notify on errors in stream --- stream-notify.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 stream-notify.sh diff --git a/stream-notify.sh b/stream-notify.sh new file mode 100644 index 0000000..2745463 --- /dev/null +++ b/stream-notify.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +usage() { + echo "Usage: $(basename $0) " +} + +if [ "$#" -ne 1 ]; then + usage + exit 1 +fi + +ssh vps "tail -n 0 -f $1" | stdbuf -o0 grep error | while IFS= read -r line +do + title=$(basename $1) + d=$(date "+%Y/%m/%d %H:%M:%S %Z") + body="$d\n$line" + notify-send "$title" "$body" +done +