aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuildos29
1 files changed, 24 insertions, 5 deletions
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" <<EOF
-$tn.bbot_cmd: ssh build@$hname ${c[@]}
-EOF
+ {
+ echo "$tn.bbot_cmd: ssh build@$hname ${c[@]}";
+ echo;
+ echo;
+ "${c[@]}" --no-pager --quiet --output short-full \
+ --since "$sd" --lines 100
+ } | email "$s"
+
toolchain_cursors["$tn"]="$nc"
fi