[systemd-devel] Fwd: mail-notify on service-restart
Reindl Harald
h.reindl at thelounge.net
Tue Sep 20 05:20:58 PDT 2011
even a try with "OnFailure=send-mail-on-failure.service" does not work
yes "systemctl start send-mail-on-failure.service" calls the script
well, this is nothing anybody wants
"killall httpd"
[root at rh:~]$ tail -f messages
Sep 20 14:10:48 rh systemd[1]: httpd.service holdoff time over, scheduling restart.
so why is "OnFailure" not executed in case "Restart=always"?
what does the %P mean in Lennart's sample "send-mail-on-failure@%P.service"
the file is not called so and i hope the intention is not creating
"send-mail-on-failure at httpd.service"
"send-mail-on-failure at mysqld.service"
.....
because systemd lacks the capability "send-mail-on-failure.service %servicename"
to have a generic restart-option for all services - there is nothing usable
to find for "OnFailure" nor how should anybody imagine what a service is
in the case of an error - for me a service is an application which is
started and runs after that
-------- Original-Nachricht --------
Betreff: [systemd-devel] mail-notify on service-restart
Datum: Tue, 20 Sep 2011 13:56:12 +0200
Von: Reindl Harald <h.reindl at thelounge.net>
Organisation: the lounge interactive design
An: Mailing-List systemd <systemd-devel at lists.freedesktop.org>
OnFailure=send-mail-on-failure@%P.service
OnFailure=send-mail-on-failure@%P
this does not work, independent of using .service or not
the whole internet has no information additional to the following thread
http://lists.freedesktop.org/archives/systemd-devel/2011-June/002699.html
> After "x" restarts have happened, the "OnFailure" unit will start
> (if specified) but only after all unsuccessfull restarts (after "x"
> restarts reached).
i maybe do not understand the context - but i do NOT need OnFailure
if restart fails - i want simply a mail EVERYTIME systemd restarts
a service even if "Restart=always" is defined and root types
"killall httpd"
_____________________
[root at rh:~]$ systemctl status send-mail-on-failure at .service
Failed to issue method call: Unit name send-mail-on-failure at .service is not valid
i do simply not understand why in the world here is a service needed
"OnFailure=/usr/bin/anyapp %P" is that what hardly is needed to get the
service-name as $1 to a script and not a additional service
in error-cases there are actions needed and not services, the targeted
shell-script could start a service if needed for whatever reason
-------- Original-Nachricht --------
Betreff: Re: [systemd-devel] Restart and RestartSec in packaged .service files
Datum: Tue, 20 Sep 2011 12:30:23 +0200
Von: Reindl Harald <h.reindl at thelounge.net>
CC: systemd-devel at lists.freedesktop.org
Am 01.09.2011 16:25, schrieb Lennart Poettering:
> if i say "Restart=always" i want a mail if this happens
> not a own unit-file
write a unit file that sends a mail, something like this:
send-mail-on-failure at .service:
<snip>
[Unit]
Description=Send mail on failure of %I
[Service]
ExecStart=/path/to/my/script.sh %I
</snip>
/path/to/my/script.sh:
<snip>
#!/bin/sh
(
echo "$1 crashed, do something, sir!"
echo "here's the systemctl status output:"
systemctl status "$1"
) | mail lennart -s "OMG! PONIES!"
</snip>
And then add OnFailure=send-mail-on-failure@%P to your units where you
want a mail to be sent
________________________
this seems not to work because after "systemctl --system daemon-reload" the
first error hits /var/log/messages and again the question why not
simplify this with "OnFailure=send-mail" instead writing scripts
and "services" to send a simple mail - this is the exact opposite
of simplify what systemd should do like Lennart always says
[root at rh:~]$ cat messages
Sep 20 12:24:36 rh systemd[1]: Reloading.
Sep 20 12:24:36 rh systemd[1]: Failed to add dependency on send-mail-on-failure@%P, ignoring: Invalid argument
[root at rh:~]$ cat /lib/systemd/system/send-mail-on-failure at .service
[Unit]
Description=Send mail on failure of %I
[Service]
ExecStart=/scripts/send-mail-on-failure.sh %I
[root at rh:~]$ cat /scripts/send-mail-on-failure.sh
#!/bin/bash
logger "SYSTEMD FAILURE $1"
[root at rh:~]$ cat /lib/systemd/system/httpd.service
[Unit]
Description=HTTP Server (prefork MPM)
After=syslog.target local-fs.target network.target mysqld.service
OnFailure=send-mail-on-failure@%P
--
Reindl Harald
the lounge interactive design GmbH
A-1060 Vienna, Hofmühlgasse 17
CTO / software-development / cms-solutions
p: +43 (1) 595 3999 33, m: +43 (676) 40 221 40
icq: 154546673, http://www.thelounge.net/
http://www.thelounge.net/signature.asc.what.htm
--
Mit besten Grüßen, Reindl Harald
the lounge interactive design GmbH
A-1060 Vienna, Hofmühlgasse 17
CTO / software-development / cms-solutions
p: +43 (1) 595 3999 33, m: +43 (676) 40 221 40
icq: 154546673, http://www.thelounge.net/
http://www.thelounge.net/signature.asc.what.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20110920/c8ee4261/attachment.pgp>
More information about the systemd-devel
mailing list