aboutsummaryrefslogtreecommitdiff
path: root/buildos
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-05-09 15:46:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-05-09 15:46:41 +0200
commit1e85919e1c3af7424a4d5bc6aef6c97b8f55c957 (patch)
treec0ef27f4260832d46e5b3dec168249409759ada8 /buildos
parent70af907ebe84d2f92364b64e693349b65b8c6fdf (diff)
Email log fragment when bbot issues diagnostics
Diffstat (limited to 'buildos')
-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