diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-07-05 14:35:19 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-07-05 14:35:19 +0200 |
commit | 8ee8274b752a6fe9c53523e8b3fd2799ccb94801 (patch) | |
tree | 80b8e391455e6cf43fd2c7c484f0a070c6069563 | |
parent | 34770f72fb2b80e7e0d260b8238b5603158723f1 (diff) |
Put bbot diagnostics into email subject line
Also handle multi-line entries in systemd journal.
-rwxr-xr-x | buildos | 31 |
1 files changed, 25 insertions, 6 deletions
@@ -1159,14 +1159,15 @@ EOF # hold space which by now should contain the last error line and # then the cursor. # - # The last chunk matches every other line. We simply replace the - # hold space with the next line so that at the end we have the - # last line there. + # The last chunk matches every other line that doesn't start + # with a space (multi-line messages). We simply replace the hold + # space with the next line so that at the end we have the last + # line there. # lr="$("${c[@]}" --priority 4 --show-cursor | sed -n -r \ -e '1{h;s/^[MTWFS].. ([^ ]+ [^ ]+) .*$/\1/p;t}' \ -e '${x;s/^[MTWFS].. ([^ ]+ [^ ]+) .*$/\1/p;x;s/^-- cursor: (.+)$/\1/p;t}' \ --e 'h')" +-e '/^[^ ]/h')" lc="$(wc -l <<<"$lr")" nc="$(sed -n -e "${lc}p" <<<"$lr")" @@ -1193,7 +1194,25 @@ EOF ed="$(date '+%s' -d "$ed")" # sec ed="$(date '+%Y-%m-%d %H:%M:%S' -d "@$(($ed + 10))")" # +10sec - s="bbot-agent-$tn@$i service issued new diagnostics" + # Include first fatal/error/warning (priority 2/3/4) in the + # subject line (note that there can be a mix so we have to + # try in the priority order). + # + p=2 + s="$("${c[@]}" --output cat --priority 2 | head -n 1)" + if [ -z "$s" ]; then + p=3 + s="$("${c[@]}" --output cat --priority 3 | head -n 1)" + if [ -z "$s" ]; then + p=4 + s="$("${c[@]}" --output cat --priority 4 | head -n 1)" + if [ -z "$s" ]; then + s="service issued new diagnostics" # Shouldn't happen. + fi + fi + fi + + s="bbot-agent-$tn@$i: $s" info "$s" { @@ -1201,7 +1220,7 @@ EOF echo; echo "summary:"; echo; - "${c[@]}" --priority 4 | head -n 200; + "${c[@]}" --priority "$p" | head -n 40; echo; echo "context:"; echo; |