[arch-general] Systemd email notifications
ushi
ushi+arch at honkgong.info
Thu Feb 13 08:21:36 EST 2014
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 13.02.2014 13:04, schrieb Paul Gideon Dann:
> Hello all,
>
> Does anyone know of any standard system for receiving notifications
> from systemd for unit state changes? I currently use Monit for the
> monitoring of many processes, and it'll e-mail me when things
> happen (e.g. a process was restarted). Since switching to systemd,
> it's felt a bit silly that for several processes, I'm having Monit
> monitor them simply because systemd is unable to tell me it
> restarted a unit. Monit isn't actually required to keep those
> processes alive as it once was, because systemd can do that.
>
> Paul
>
Hey Paul,
Check out OnFailure=
[Unit]
Description="HTTP Service"
OnFailure=mail-root at http.service
...
The mail-root at .service is a generic oneshot service that mails you
some stuff.
[Unit]
Description="Mailer"
[Service]
Type=oneshot
ExecStart=/path/to/my/mail-script %i
[Install]
WantedBy=multi-user.target
And your mail-script is somthing like...
#!/usr/bin/env sh
systemctl status "${1}.service" | \
mail -s "Failed Service: ${1}" admin at example.com
See:
http://www.freedesktop.org/software/systemd/man/systemd.unit.html#OnFailure=
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJS/MbgAAoJEAAoDO4PlX3giMIQAL0sjwOpJ/QRYA0+stZQXONs
GPAvF75G0oxKV8D0vv6Ywr0UBq+OeuXYUWYoH4Iv+O9sKEKs3Jml8ecalLTogvr/
cx8Ux+ICdMN2O8WrLfb38Ui/Vo4I/O0te2oxlTzA1/TcFfYnyFfAoMm5JYsxAUva
aXHUJwOVVDCcaQFUHG17nzh3iKLzCGbKkVvzfcvjsWVzapbRbdnKRoOOnVfsyA6U
BO5sgLbyJ/zIFCQYxS0380YBQfG34u5wISMjBOcfTCLBubB3yemScmO8OJKIRjGM
hiKyWUtfTZrY5KQfhdN3+UcvdLU8ilv938/aI2bD1JGEvX1fWS4STsajwgKq/PoS
p1O5OHCipvNrfrkzBOKMVDYpYMWpz1OI36wD0wHqp6VcYHVDDcDkayjq0avCcEyO
6p5vDt7z3avvsyvrRYgPlMZF/Jc+pd6UeoFWahtIUbvJJlbX4wK8cZFun2QJmUL0
49ZQdNYpekNNXe9cJn6FcXMVcATPk2xhqBn2PDECQE5B1ATmzsOZ+aEyPiWemxhX
snZT1dLEZmJBFC9xg/5m1BBs0mmCY+ermpFZJniMrwFiSR9uIaastNPARfPIVUvp
rZ0r/JTPVZ0x8wMF9QXbS90zjcQ2O+bMae2BojiYEE9CdPNnacE2W0VK2uzGBWz8
/evt18eKs28cWufnC6F4
=1w4X
-----END PGP SIGNATURE-----
More information about the arch-general
mailing list