summarylogtreecommitdiffstats
path: root/unit-status-mail
blob: 46fc64381c1ccdafd54e4f75e012be10785568e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
MAILTO="root"
MAILFROM="unit-status-mailer"
UNIT=$1
DATE=$(date '+%F')

EXTRA=""
for e in "${@:2}"; do
  EXTRA+="$e"$'\n'
done

UNITSTATUS=$(journalctl -S $DATE -l -n 100000 -u $UNIT)

sendmail $MAILTO <<ENDOFMAILCONTENT
From:$MAILFROM
To:$MAILTO
Subject:Status mail for unit: $UNIT
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

Status report for unit: $UNIT
$EXTRA

$UNITSTATUS
ENDOFMAILCONTENT

echo -e "Status mail sent to: $MAILTO for unit: $UNIT"