[arch-general] Systemd email notifications

Thomas Bächler thomas at archlinux.org
Thu Feb 13 07:35:59 EST 2014


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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-general/attachments/20140213/1d8a74cf/attachment-0001.asc>


More information about the arch-general mailing list