[systemd-devel] How to set `InitRDTimestampMonotonic` from console?

aleivag aleivag at gmail.com
Wed Jul 4 05:40:42 UTC 2018


Hi Paul:

properties on the manager object, you can get them with:

[~] sudo systemctl show -p InitRDTimestampMonotonic
InitRDTimestampMonotonic=0

there is also the long way:

[~] busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1
org.freedesktop.systemd1.Manager InitRDTimestampMonotonic
t 0

if you want to get this value from a shell script, you can use either, but
i recommend `systemctl show`. if you can aford not to run this on shell,
and do it in c, just bind against libsystemd and call methods in
systemd/sd-bus.h , and if you can run stuff on high level languages like
python... try pystemd (but i'm bias against the last one because i'm the
author and its not a official systemd tool)

best of lucks


Alvaro Leiva


On Tue, Jul 3, 2018 at 10:24 PM Paul Menzel <
pmenzel+systemd-devel at molgen.mpg.de> wrote:

> Dear systemd folks,
>
>
> Debian uses a shell script as `/init` in initrd, and I like to extend
> that, to set the time stamps for the initrd execution.
>
> `systemd-analyze` built from `src/analyze/analyze.c` uses D-Bus to get
> the time stamp to display that.
>
> ```
>             bus_get_uint64_property(bus,
>                                      "/org/freedesktop/systemd1",
>                                      "org.freedesktop.systemd1.Manager",
>                                      "InitRDTimestampMonotonic",
>                                      &times.initrd_time) < 0
> ```
>
> In `src/core/manager.c` the value is set like below.
>
> ```
>                  if
> (dual_timestamp_is_set(&m->timestamps[MANAGER_TIMESTAMP_INITRD])) {
>
>                          /* The initrd case on bare-metal*/
>                          kernel_usec =
> m->timestamps[MANAGER_TIMESTAMP_INITRD].monotonic -
> m->timestamps[MANAGER_TIMESTAMP_KERNEL].monotonic;
>                          initrd_usec =
> m->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic -
> m->timestamps[MANAGER_TIMESTAMP_INITRD].monotonic;
>
>                          log_struct(LOG_INFO,
>                                     "MESSAGE_ID="
> SD_MESSAGE_STARTUP_FINISHED_STR,
>                                     "KERNEL_USEC="USEC_FMT, kernel_usec,
>                                     "INITRD_USEC="USEC_FMT, initrd_usec,
>                                     "USERSPACE_USEC="USEC_FMT,
> userspace_usec,
>                                     LOG_MESSAGE("Startup finished in
> %s%s (kernel) + %s (initrd) + %s (userspace) = %s.",
>                                                 buf,
>                                                 format_timespan(kernel,
> sizeof(kernel), kernel_usec, USEC_PER_MSEC),
>                                                 format_timespan(initrd,
> sizeof(initrd), initrd_usec, USEC_PER_MSEC),
>
> format_timespan(userspace, sizeof(userspace), userspace_usec,
> USEC_PER_MSEC),
>                                                 format_timespan(sum,
> sizeof(sum), total_usec, USEC_PER_MSEC)));
> ```
>
>
>
>
> Is it possible to set that value from a shell script? If yes, could you
> please tell me how?
>
>
> Kind regards,
>
> Paul
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180703/7122484f/attachment.html>


More information about the systemd-devel mailing list