Notify on errors in stream

This commit is contained in:
ekzyis 2023-11-23 21:15:31 +01:00
parent 96f2099ca1
commit ab5fd49157
1 changed files with 19 additions and 0 deletions

19
stream-notify.sh Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
usage() {
echo "Usage: $(basename $0) <file>"
}
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