On 13 February 2014 13:35, Paul Gideon Dann <pdgiddie@xxxxxxxxx> wrote: > On Thursday 13 Feb 2014 14:21:36 ushi wrote: >> 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@http.service >> ... >> >> The mail-root@.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@xxxxxxxxxxx >> >> See: >> http://www.freedesktop.org/software/systemd/man/systemd.unit.html#OnFailure= > > Thanks ushi, that's certainly something. It looks promising for custom unit files, but not > so great for catching unexpected unit failures. I'll definitely keep that one in mind, > though. You could use unit overrides[0] to add the OnFailure to provided units. So should be able to set it up for any service you are interested in receiving notifications for, I would assume. [0] https://wiki.archlinux.org/index.php/Systemd#Editing_provided_unit_files