Script to send mail from systemd timers on failure
This commit is contained in:
parent
9c2868feda
commit
20bbee7a56
1 changed files with 25 additions and 0 deletions
25
unit_mail.sh
Executable file
25
unit_mail.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
MAILTO="root"
|
||||
MAILFROM="root@internal.heavensinferno.net"
|
||||
UNIT=$1
|
||||
|
||||
EXTRA=""
|
||||
for e in "${@:2}"; do
|
||||
EXTRA+="$e"$'\n'
|
||||
done
|
||||
|
||||
UNITSTATUS=$(systemctl status $UNIT)
|
||||
|
||||
sendmail $MAILTO <<EOF
|
||||
From:$MAILFROM
|
||||
To: $MAILTO
|
||||
Subject:[systemd timer] Status mail for unit: $UNIT
|
||||
|
||||
Status report for unit: $UNIT
|
||||
$EXTRA
|
||||
|
||||
$UNITSTATUS
|
||||
EOF
|
||||
|
||||
echo -e "Status mail sent to: $MAILTO for unit: $UNIT"
|
||||
|
Loading…
Add table
Reference in a new issue