add timestamp to mailed journal log.

Also restrict to 200 rows to prevent unreasonable large emails...
This commit is contained in:
Fredrik Eriksson 2024-07-14 16:07:11 +02:00
parent 8abf7d89f6
commit 93f5a9aaad
Signed by: feffe
GPG Key ID: E6B5580B853D322B

View File

@ -50,7 +50,11 @@ def failure(name, failures, config):
reader.add_match(MONITOR_INVOCATION_ID=latest_inv_id) reader.add_match(MONITOR_INVOCATION_ID=latest_inv_id)
reader.add_disjunction() reader.add_disjunction()
reader.add_match(_SYSTEMD_INVOCATION_ID=latest_inv_id) reader.add_match(_SYSTEMD_INVOCATION_ID=latest_inv_id)
journal_txt = "\n".join([entry['MESSAGE'] for entry in reader]) journal_txt = "\n".join(
[
f'{entry["_SOURCE_REALTIME_TIMESTAMP"]}: {entry["MESSAGE"]}'
for entry in list(reader)[-200:]
])
if nr_failures <= 1: if nr_failures <= 1:
subject=f"{hostname} - {name}: failure" subject=f"{hostname} - {name}: failure"