quickvm / blazon

A bash script and systemd unit to prominently notify you of systemd unit failures.
MIT License
2 stars 0 forks source link

Support for Email Notifications #1

Open LorbusChris opened 1 year ago

LorbusChris commented 1 year ago

Support for Email Notifications might be useful. I'm using this via OnFailure=email-notification@%n.service on my servers:

/usr/libexec/systemd-email-notification:

#!/bin/bash
set -euo pipefail

systemctl status --full "${1}" | mail -Ssendwait -s "systemd Email Notification: ${1}" ${2:-default}

/etc/systemd/system/email-notification@.service:

[Unit]
Description=Send status email for %i service

[Service]
Type=oneshot
ExecStart=/usr/libexec/systemd-email-notification %i
jdoss commented 1 year ago

Does this need an MTA installed? I assume yes?

LorbusChris commented 1 year ago

it does, yes

jdoss commented 1 year ago

If you want to add it in Chris feel free to send a PR. Otherwise, I will try to add it in soon.