systemd-unit-status-mail
Be notified via e-mail when a systemd unit enters failed state. Based on this blog post.
Installation
-
Decide where you want to install things.
INSTALL_DIR=/usr/local/src/systemd-unit-status-mail
-
Clone this repository.
$ git clone https://github.com/agross/systemd-unit-status-mail.git "$INSTALL_DIR" Cloning into 'systemd-unit-status-mail'...
-
Install the systemd unit.
$ "$INSTALL_DIR/install" Linking /usr/local/src/systemd-unit-status-mail/[email protected] Linking /usr/local/src/systemd-unit-status-mail/unit-status-mail
-
Tell
[email protected]
who should receive notifications.$ systemctl edit [email protected] # Editor opens. Add these lines and save the file. [Service] [email protected],[email protected]
-
Configure units that you want to be notified about.
$ systemctl edit some.service # Editor opens. Add these lines and save the file. [Unit] OnFailure=unit-status-mail@%n.service
Optional configuration items to think about
Test your setup
$ UNIT=auditd.service
$ systemctl start unit-status-mail@$UNIT.service
$ systemctl status unit-status-mail@$UNIT.service
● [email protected] - Unit Status Mailer Service
Loaded: loaded (/usr/local/src/systemd-unit-status-mail/[email protected]; linked; vendor preset: disabled)
Drop-In: /etc/systemd/system/[email protected]
└─override.conf
Active: inactive (dead)
Jan 22 18:45:11 fedja.wghoch4.local systemd[1]: Starting Unit Status Mailer Service...
Jan 22 18:45:11 fedja.wghoch4.local unit-status-mail[13876]: <13>Jan 22 18:45:11 /etc/systemd/system/unit-status-mail: Status mail sent to [email protected],[email protected] for unit auditd.service
Jan 22 18:45:13 fedja.wghoch4.local systemd[1]: Started Unit Status Mailer Service.
Getting the whole picture
To get all [email protected]
settings use
systemctl cat [email protected]
andsystemctl show [email protected]
.