Re: Systemd email notifications

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



Am 13.02.2014 13:04, schrieb Paul Gideon Dann:
> 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.

I'd place a bet on the systemd dbus API: IIRC, it exports the state of
each unit as a property and then emits the standard
org.freedesktop.DBus.Properties.PropertiesChanged signal when the state
changes.

So, your task would be to subscribe to that signal and act on it. This
could be nicely done in python (and maybe someone has done it already).

I just listed some properties using qdbus:

$ qdbus --system org.freedesktop.systemd1
/org/freedesktop/systemd1/unit/dbus_2eservice
org.freedesktop.DBus.Properties.Get org.freedesktop.systemd1.Unit
ActiveState

active

$ qdbus --system org.freedesktop.systemd1
/org/freedesktop/systemd1/unit/dbus_2eservice
org.freedesktop.DBus.Properties.Get org.freedesktop.systemd1.Unit SubState

running

$ qdbus --system org.freedesktop.systemd1
/org/freedesktop/systemd1/unit/dbus_2eservice
org.freedesktop.DBus.Properties.Get org.freedesktop.systemd1.Service MainPID

391

Surely, the ActiveState, SubState and MainPID properties would change
when something gets restarted or stopped, and you would receive the
PropertiesChanged signal.

Attachment: signature.asc
Description: OpenPGP digital signature


[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