1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2012 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_journal_get_realtime_usec">
27 <title>sd_journal_get_realtime_usec</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_journal_get_realtime_usec</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_journal_get_realtime_usec</refname>
47 <refname>sd_journal_get_monotonic_usec</refname>
48 <refpurpose>Read timestamps from the current journal entry</refpurpose>
53 <funcsynopsisinfo>#include <systemd/sd-journal.h></funcsynopsisinfo>
56 <funcdef>int <function>sd_journal_get_realtime_usec</function></funcdef>
57 <paramdef>sd_journal* <parameter>j</parameter></paramdef>
58 <paramdef>uint64_t* <parameter>usec</parameter></paramdef>
62 <funcdef>int <function>sd_journal_get_monotonic_usec</function></funcdef>
63 <paramdef>sd_journal* <parameter>j</parameter></paramdef>
64 <paramdef>uint64_t* <parameter>usec</parameter></paramdef>
65 <paramdef>sd_id128_t* <parameter>boot_id</parameter></paramdef>
72 <title>Description</title>
74 <para><function>sd_journal_get_realtime_usec()</function>
75 gets the realtime (wallclock) timestamp of the
76 current journal entry. It takes two arguments: the
77 journal context object and a pointer to a 64 Bit
78 unsigned integer to store the timestamp in. The
79 timestamp is in microseconds since the epoch,
80 i.e. CLOCK_REALTIME.</para>
82 <para><function>sd_journal_get_monotonic_usec()</function>
83 gets the monotonic timestamp of the current
84 journal entry. It takes three arguments: the journal
85 context object, a pointer to a 64 Bit unsigned integer
86 to store the timestamp in as well as a 128 Bit ID
87 buffer to store the boot ID of the monotonic timestamp
88 in. The timestamp is in microseconds since boot-up of
89 the specific boot, i.e. CLOCK_MONOTONIC. Since the
90 monotonic clock begins new with every reboot it only
91 defines a well-defined point in time when used
92 together with an identifier identifying the boot, see
93 <citerefentry><refentrytitle>sd_id128_get_boot</refentrytitle><manvolnum>3</manvolnum></citerefentry>
94 for more information. If the boot ID parameter is
95 passed NULL the function will fail if the monotonic
96 timestamp of the current entry is not of the current
99 <para>Note that these functions will not work before
100 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
101 (or related call) has been called at least
102 once, in order to position the read pointer at a valid entry.</para>
106 <title>Return Value</title>
108 <para><function>sd_journal_get_realtime_usec()</function>
110 <function>sd_journal_get_monotonic_usec()</function>
111 returns 0 on success or a negative errno-style error
112 code. If the boot ID parameter was passed NULL and the
113 monotonic timestamp of the current journal entry is
114 not of the current system boot, -ESTALE is returned by <function>sd_journal_get_monotonic_usec()</function>.</para>
121 <function>sd_journal_get_realtime_usec()</function>
123 <function>sd_journal_get_monotonic_usec()</function>
124 interfaces are available as shared library, which can
125 be compiled and linked to with the
126 <literal>libsystemd-journal</literal>
127 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
132 <title>See Also</title>
135 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
137 <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
138 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
139 <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
140 <citerefentry><refentrytitle>sd_id128_get_boot</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
141 <citerefentry><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
142 <citerefentry><refentrytitle>sd_journal_get_cutoff_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>