From 1e85919e1c3af7424a4d5bc6aef6c97b8f55c957 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 9 May 2017 15:46:41 +0200 Subject: Email log fragment when bbot issues diagnostics --- buildos | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'buildos') diff --git a/buildos b/buildos index 8dfd3d3..78c16c2 100755 --- a/buildos +++ b/buildos @@ -985,18 +985,37 @@ EOF c+=("--after-cursor" "$oc") fi - nc="$("${c[@]}" --no-pager --quiet --priority 4 --show-cursor | \ -sed -n -re 's/^-- cursor: (.+)$/\1/p')" + # Get the log range: the first line is the date of the first error + # and the second line is the end cursor. + # + lr="$("${c[@]}" --no-pager --quiet --output short-full \ +--priority 4 --show-cursor | \ +sed -n -re '1s/^... ([^ ]+ [^ ]+) .*$/\1/p;s/^-- cursor: (.+)$/\1/p')" + + nc="$(sed -n -e '2p' <<<"$lr")" # If we have no new entries, then nothing to do. # if [ -n "$nc" -a "$nc" != "$oc" ]; then + + # Try to get some context for the first error entry. This is + # unexpectedly hard in systemd. So we are going to get all the + # entries that start a minute ago. + # + sd="$(sed -n -e '1p' <<<"$lr")" + sd="$(date '+%Y-%m-%d %H:%M:%S' -d "$sd +00:01")" + s="bbot-agent@$tn service issued new diagnostics" info "$s" - email "$s" <