ansible-sendmail/templates/notify_unit_failure.sh

17 lines
300 B
Bash
Executable File

#!/usr/bin/env bash
INVOCATION_ID=$(systemctl show -p InvocationID --value ${1}.service)
cat << EOM | sendmail \
-section unit_failure \
-sub "[UNIT-FAILURE|$(hostname)] ${1}"
The unit ${1}.service just failed
Date: $(date)
---
$(journalctl _SYSTEMD_INVOCATION_ID=${INVOCATION_ID})
EOM