Discussion:
custom var in sd_notify
(too old to reply)
aleivag
2018-02-25 22:32:50 UTC
Permalink
Hi all, hope you are doing:

i was toying aroud sd_notify and sd-daemon.h and found this section in
https://github.com/systemd/systemd/blob/master/src/
systemd/sd-daemon.h#L234-L235 it said:

Daemons can choose to send additional variables. However, it is recommended
to prefix variable names not listed above with X_.
So naturally i tried

sd_notify(0, "X_ANSWER=42")

and apparently systemd has no problem with that, but my questions are 2 now:

1) What does systemd do with this information?
2) How can i query this x_answer variable i just gave?

thanks!

Alvaro Leiva
Mantas Mikulėnas
2018-02-26 06:09:36 UTC
Permalink
Post by aleivag
i was toying aroud sd_notify and sd-daemon.h and found this section in
https://github.com/systemd/systemd/blob/master/src/system
Daemons can choose to send additional variables. However, it is recommended
to prefix variable names not listed above with X_.
So naturally i tried
sd_notify(0, "X_ANSWER=42")
1) What does systemd do with this information?
Nothing. The documentation just says in other words that "the init system
must not reject packets with unknown variables", but doesn't say that
systemd or any other init will store all of them anywhere.
--
Mantas Mikulėnas
aleivag
2018-02-26 14:43:25 UTC
Permalink
It make sense, Thank you for the clarification!
Post by aleivag
i was toying aroud sd_notify and sd-daemon.h and found this section in
https://github.com/systemd/systemd/blob/master/src/system
Daemons can choose to send additional variables. However, it is recommended
to prefix variable names not listed above with X_.
So naturally i tried
sd_notify(0, "X_ANSWER=42")
1) What does systemd do with this information?
Nothing. The documentation just says in other words that "the init system
must not reject packets with unknown variables", but doesn't say that
systemd or any other init will store all of them anywhere.
--
Mantas Mikulėnas
Lennart Poettering
2018-02-28 18:04:53 UTC
Permalink
Post by Mantas Mikulėnas
Post by aleivag
Daemons can choose to send additional variables. However, it is recommended
to prefix variable names not listed above with X_.
So naturally i tried
sd_notify(0, "X_ANSWER=42")
1) What does systemd do with this information?
Nothing. The documentation just says in other words that "the init system
must not reject packets with unknown variables", but doesn't say that
systemd or any other init will store all of them anywhere.
Currently we indeed ignore those unknown variables entirely. It has
been requested that we expose these variables on the bus somehow. I
think that would be an OK addition, but we need to think about the
lifecycle of those vars then so that the vars we collect don't grow
without bounds.

Lennart
--
Lennart Poettering, Red Hat
Umut Tezduyar Lindskog
2018-03-01 10:09:20 UTC
Permalink
On Wed, Feb 28, 2018 at 7:04 PM, Lennart Poettering
Post by Lennart Poettering
Post by Mantas Mikulėnas
Post by aleivag
Daemons can choose to send additional variables. However, it is recommended
to prefix variable names not listed above with X_.
So naturally i tried
sd_notify(0, "X_ANSWER=42")
1) What does systemd do with this information?
Nothing. The documentation just says in other words that "the init system
must not reject packets with unknown variables", but doesn't say that
systemd or any other init will store all of them anywhere.
Currently we indeed ignore those unknown variables entirely. It has
been requested that we expose these variables on the bus somehow. I
think that would be an OK addition, but we need to think about the
lifecycle of those vars then so that the vars we collect don't grow
without bounds.
I believe this is what we do with STATUS: messages today. I was just
curious if there is a rate limit around this sd_notify interface.

UMUT
Post by Lennart Poettering
Lennart
--
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Lennart Poettering
2018-03-01 10:23:02 UTC
Permalink
Post by Umut Tezduyar Lindskog
On Wed, Feb 28, 2018 at 7:04 PM, Lennart Poettering
Post by Lennart Poettering
Post by Mantas Mikulėnas
Post by aleivag
Daemons can choose to send additional variables. However, it is recommended
to prefix variable names not listed above with X_.
So naturally i tried
sd_notify(0, "X_ANSWER=42")
1) What does systemd do with this information?
Nothing. The documentation just says in other words that "the init system
must not reject packets with unknown variables", but doesn't say that
systemd or any other init will store all of them anywhere.
Currently we indeed ignore those unknown variables entirely. It has
been requested that we expose these variables on the bus somehow. I
think that would be an OK addition, but we need to think about the
lifecycle of those vars then so that the vars we collect don't grow
without bounds.
I believe this is what we do with STATUS: messages today. I was just
curious if there is a rate limit around this sd_notify interface.
No, it's an AF_UNIX socket. That means we have to process the queued
datagrams in order.

Of course clients might decide to skip enqueuing messages if the
socket buffer is full (i.e. by setting O_NONBLOCK on the socket and
checking for EAGAIN), however that's purely on the client-side, PID 1
can't really do much else than process every single message, there's
no ratelimit.

Lennart
--
Lennart Poettering, Red Hat
Loading...