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

Paul Menzel pmenzel+systemd-devel at molgen.mpg.de
Wed Jul 4 05:24:15 UTC 2018


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


More information about the systemd-devel mailing list