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"
>   [email protected]
>   ...
> 
> The [email protected] 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}" [email protected]
> 
> 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.

Paul

Reply via email to