]>
Commit | Line | Data |
---|---|---|
37a40afc LP |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | <!-- SPDX-License-Identifier: LGPL-2.1-or-later --> | |
5 | ||
6 | <refentry id="sd_journal_get_seqnum" | |
7 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
8 | ||
9 | <refentryinfo> | |
10 | <title>sd_journal_get_seqnum</title> | |
11 | <productname>systemd</productname> | |
12 | </refentryinfo> | |
13 | ||
14 | <refmeta> | |
15 | <refentrytitle>sd_journal_get_seqnum</refentrytitle> | |
16 | <manvolnum>3</manvolnum> | |
17 | </refmeta> | |
18 | ||
19 | <refnamediv> | |
20 | <refname>sd_journal_get_seqnum</refname> | |
21 | <refpurpose>Read sequence number from the current journal entry</refpurpose> | |
22 | </refnamediv> | |
23 | ||
24 | <refsynopsisdiv> | |
25 | <funcsynopsis> | |
26 | <funcsynopsisinfo>#include <systemd/sd-journal.h></funcsynopsisinfo> | |
27 | ||
28 | <funcprototype> | |
29 | <funcdef>int <function>sd_journal_get_seqnum</function></funcdef> | |
30 | <paramdef>sd_journal *<parameter>j</parameter></paramdef> | |
31 | <paramdef>uint64_t *<parameter>ret_seqnum</parameter></paramdef> | |
32 | <paramdef>sd_id128_t *<parameter>ret_seqnum_id</parameter></paramdef> | |
33 | </funcprototype> | |
34 | </funcsynopsis> | |
35 | </refsynopsisdiv> | |
36 | ||
37 | <refsect1> | |
38 | <title>Description</title> | |
39 | ||
40 | <para><function>sd_journal_get_seqnum()</function> returns the sequence number of the current journal | |
41 | entry. It takes three arguments: the journal context object, a pointer to a 64-bit unsigned integer to | |
da890466 | 42 | store the sequence number in, and a buffer to return the 128-bit sequence number ID in.</para> |
37a40afc LP |
43 | |
44 | <para>When writing journal entries to disk each <command>systemd-journald</command> instance will number | |
60c5bd77 | 45 | them sequentially, starting from 1 for the first entry written after subsystem initialization. Each such |
da890466 | 46 | series of sequence numbers is associated with a 128-bit sequence number ID which is initialized randomly, |
37a40afc LP |
47 | once at <command>systemd-journal</command> initialization. Thus, while multiple instances of |
48 | <command>systemd-journald</command> will assign the same sequence numbers to their written journal | |
49 | entries, they will have a distinct sequence number IDs. The sequence number is assigned at the moment of | |
50 | writing the entry to disk. If log entries are rewritten (for example because the volatile logs from | |
51 | <filename>/run/log/</filename> are flushed to <filename>/var/log/</filename> via | |
52 | <filename>systemd-journald-flush.service</filename>) they will get new sequence numbers assigned.</para> | |
53 | ||
54 | <para>Sequence numbers may be used to order entries (entries associated with the same sequence number ID | |
55 | and lower sequence numbers should be ordered chronologically before those with higher sequence numbers), | |
56 | and to detect lost entries. Note that journal service instances typically write to multiple journal files | |
57 | in parallel (for example because <varname>SplitMode=</varname> is used), in which case each journal file | |
58 | will only contain a subset of the sequence numbers. To recover the full stream of journal entries the | |
59 | files must be combined ("interleaved"), a process that primarily relies on the sequence numbers. When | |
60 | journal files are rotated (due to size or time limits), the series of sequence numbers is continued in | |
61 | the replacement files. All journal files generated from the same journal instance will carry the same | |
62 | sequence number ID.</para> | |
63 | ||
64 | <para>As the sequence numbers are assigned at the moment of writing the journal entries to disk they do | |
65 | not exist if storage is disabled via <varname>SplitMode=</varname>.</para> | |
66 | ||
67 | <para>The <varname>ret_seqnum</varname> and <varname>ret_seqnum_id</varname> parameters may be specified | |
68 | as <constant>NULL</constant> in which case the relevant data is not returned (but the call will otherwise | |
69 | succeed).</para> | |
70 | ||
71 | <para>Note that these functions will not work before | |
72 | <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
73 | (or related call) has been called at least | |
74 | once, in order to position the read pointer at a valid entry.</para> | |
75 | </refsect1> | |
76 | ||
77 | <refsect1> | |
78 | <title>Return Value</title> | |
79 | ||
80 | <para><function>sd_journal_get_seqnum()</function> returns 0 on success or a negative errno-style error | |
81 | code..</para> | |
82 | </refsect1> | |
83 | ||
84 | <refsect1> | |
85 | <title>Notes</title> | |
86 | ||
87 | <xi:include href="threads-aware.xml" xpointer="strict"/> | |
88 | ||
89 | <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/> | |
90 | </refsect1> | |
91 | ||
92 | <refsect1> | |
93 | <title>See Also</title> | |
94 | ||
95 | <para> | |
96 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
97 | <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
98 | <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
99 | <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
100 | <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
101 | <citerefentry><refentrytitle>sd_journal_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
102 | </para> | |
103 | </refsect1> | |
104 | ||
105 | </refentry> |