]>
Commit | Line | Data |
---|---|---|
7a8a6e88 LP |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
12b42c76 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
7a8a6e88 LP |
4 | |
5 | <!-- | |
572eb058 ZJS |
6 | SPDX-License-Identifier: LGPL-2.1+ |
7 | ||
7a8a6e88 LP |
8 | This file is part of systemd. |
9 | ||
10 | Copyright 2012 Lennart Poettering | |
11 | ||
12 | systemd is free software; you can redistribute it and/or modify it | |
13 | under the terms of the GNU Lesser General Public License as published by | |
14 | the Free Software Foundation; either version 2.1 of the License, or | |
15 | (at your option) any later version. | |
16 | ||
17 | systemd is distributed in the hope that it will be useful, but | |
18 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | Lesser General Public License for more details. | |
21 | ||
22 | You should have received a copy of the GNU Lesser General Public License | |
23 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
24 | --> | |
25 | ||
26 | <refentry id="sd_journal_get_realtime_usec"> | |
27 | ||
798d3a52 ZJS |
28 | <refentryinfo> |
29 | <title>sd_journal_get_realtime_usec</title> | |
30 | <productname>systemd</productname> | |
31 | ||
32 | <authorgroup> | |
33 | <author> | |
34 | <contrib>Developer</contrib> | |
35 | <firstname>Lennart</firstname> | |
36 | <surname>Poettering</surname> | |
37 | <email>lennart@poettering.net</email> | |
38 | </author> | |
39 | </authorgroup> | |
40 | </refentryinfo> | |
41 | ||
42 | <refmeta> | |
43 | <refentrytitle>sd_journal_get_realtime_usec</refentrytitle> | |
44 | <manvolnum>3</manvolnum> | |
45 | </refmeta> | |
46 | ||
47 | <refnamediv> | |
48 | <refname>sd_journal_get_realtime_usec</refname> | |
49 | <refname>sd_journal_get_monotonic_usec</refname> | |
50 | <refpurpose>Read timestamps from the current journal entry</refpurpose> | |
51 | </refnamediv> | |
52 | ||
53 | <refsynopsisdiv> | |
54 | <funcsynopsis> | |
55 | <funcsynopsisinfo>#include <systemd/sd-journal.h></funcsynopsisinfo> | |
56 | ||
57 | <funcprototype> | |
58 | <funcdef>int <function>sd_journal_get_realtime_usec</function></funcdef> | |
59 | <paramdef>sd_journal *<parameter>j</parameter></paramdef> | |
60 | <paramdef>uint64_t *<parameter>usec</parameter></paramdef> | |
61 | </funcprototype> | |
62 | ||
63 | <funcprototype> | |
64 | <funcdef>int <function>sd_journal_get_monotonic_usec</function></funcdef> | |
65 | <paramdef>sd_journal *<parameter>j</parameter></paramdef> | |
66 | <paramdef>uint64_t *<parameter>usec</parameter></paramdef> | |
67 | <paramdef>sd_id128_t *<parameter>boot_id</parameter></paramdef> | |
68 | </funcprototype> | |
69 | ||
70 | </funcsynopsis> | |
71 | </refsynopsisdiv> | |
72 | ||
73 | <refsect1> | |
74 | <title>Description</title> | |
75 | ||
76 | <para><function>sd_journal_get_realtime_usec()</function> gets the | |
77 | realtime (wallclock) timestamp of the current journal entry. It | |
78 | takes two arguments: the journal context object and a pointer to a | |
79 | 64-bit unsigned integer to store the timestamp in. The timestamp | |
80 | is in microseconds since the epoch, i.e. | |
81 | <constant>CLOCK_REALTIME</constant>.</para> | |
82 | ||
83 | <para><function>sd_journal_get_monotonic_usec()</function> gets | |
84 | the monotonic timestamp of the current journal entry. It takes | |
85 | three arguments: the journal context object, a pointer to a 64-bit | |
86 | unsigned integer to store the timestamp in, as well as a 128-bit | |
87 | ID buffer to store the boot ID of the monotonic timestamp. The | |
88 | timestamp is in microseconds since boot-up of the specific boot, | |
89 | i.e. <constant>CLOCK_MONOTONIC</constant>. Since the monotonic | |
90 | clock begins new with every reboot, it only defines a well-defined | |
91 | point in time when used together with an identifier identifying | |
92 | 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 passed | |
95 | <constant>NULL</constant>, the function will fail if the monotonic | |
96 | timestamp of the current entry is not of the current system | |
97 | boot.</para> | |
98 | ||
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> | |
103 | </refsect1> | |
104 | ||
105 | <refsect1> | |
106 | <title>Return Value</title> | |
107 | ||
108 | <para><function>sd_journal_get_realtime_usec()</function> and | |
109 | <function>sd_journal_get_monotonic_usec()</function> returns 0 on | |
110 | success or a negative errno-style error code. If the boot ID | |
111 | parameter was passed <constant>NULL</constant> and the monotonic | |
112 | timestamp of the current journal entry is not of the current | |
113 | system boot, <constant>-ESTALE</constant> is returned by | |
114 | <function>sd_journal_get_monotonic_usec()</function>.</para> | |
115 | </refsect1> | |
116 | ||
117 | <refsect1> | |
118 | <title>Notes</title> | |
119 | ||
120 | <para>The <function>sd_journal_get_realtime_usec()</function> and | |
121 | <function>sd_journal_get_monotonic_usec()</function> interfaces | |
122 | are available as a shared library, which can be compiled and | |
123 | linked to with the | |
124 | <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
125 | file.</para> | |
126 | </refsect1> | |
127 | ||
128 | <refsect1> | |
129 | <title>See Also</title> | |
130 | ||
131 | <para> | |
132 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
133 | <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
134 | <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
135 | <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
136 | <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
137 | <citerefentry><refentrytitle>sd_id128_get_boot</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
138 | <citerefentry><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>, | |
139 | <citerefentry><refentrytitle>sd_journal_get_cutoff_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
140 | </para> | |
141 | </refsect1> | |
7a8a6e88 LP |
142 | |
143 | </refentry> |