Re: Systemd email notifications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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.

Paul


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux