<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Interesting point, thanks for the clarifications. I thought that it
would be as simple as setting the environmental variables
DBUS_SESSION_BUS_ADRESS and DISPLAY at each unit file that you would
want to receive notifications from.I thought that i might have not
seen all the directives of systemd and perhaps there was one already
to call an external script. But thanks anyway<br>
<div class="moz-cite-prefix">On 02/06/2015 09:23 PM, Mantas
Mikulėnas wrote:<br>
</div>
<blockquote
cite="mid:CAPWNY8UUFaFmi04++XY+jOs8N7JGSqmkZO8ANw=nGFWvVwDDuw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Fri, Feb 6, 2015 at 5:26 PM,
George Karakougioumtzis <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:mad-proffessor@hotmail.com" target="_blank">mad-proffessor@hotmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi.
Congrats for the near perfect job on systemd! I was
searching for a<br>
directive to execute a script upon systemd service
failure. I would like<br>
to receive desktop notifications about such failures. I
stumbled upon<br>
OnFailure and FailureAction but these have hardcoded list
of actions?<br>
</blockquote>
<div><br>
</div>
<div>One of those actions is "start an arbitrary unit",
which could handle notifications... Unfortunately it
doesn't actually pass any failure information to that
unit. So, instead, you might have to watch the system log
(journal) for unit failure notices. (I would normally have
said that the journal makes it easy to filter for them,
but quite strangely, these ones don't have a MESSAGE_ID
attached...)</div>
<div><br>
</div>
<div>Maybe others will have better suggestions.<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Any
hints how to get notified (with notify-send most likely)?</blockquote>
<div><br>
</div>
<div>systemd calling notify-send isn't going to happen – as
a service, it runs "outside" your desktop session, and has
no access to its D-Bus session bus, which tends to be
started at a random address. (There might even be several
sessions, not just one!) And even considering the future
"user bus" plans (which would put the session bus at a
known fixed location), the whole idea of having a service
inject something into a desktop session is really ugly.
Even Microsoft realized that and implemented "session 0
isolation" in VIsta.</div>
<div><br>
</div>
<div>In other words, such a notifier would need to be
started from within your desktop session, connect <i>to</i> systemd
(either by waiting for signals on the system bus or by
watching the journal messages), and idle in background
waiting for some unit to fail. With DBus it could be a
simple 10-line script, waiting for signals on one bus and
calling Notify() on another...</div>
</div>
<div><br>
</div>
-- <br>
<div class="gmail_signature">
<div dir="ltr">Mantas Mikulėnas <<a
moz-do-not-send="true" href="mailto:grawity@gmail.com"
target="_blank">grawity@gmail.com</a>></div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>