1 |
On Tue, Feb 18, 2014 at 3:54 AM, J. Roeleveld <joost@××××××××.org> wrote: |
2 |
> On Sun, February 16, 2014 22:16, Canek Peláez Valdés wrote: |
3 |
>> On Sun, Feb 16, 2014 at 2:58 PM, Volker Armin Hemmann |
4 |
>> <volkerarmin@××××××××××.com> wrote: |
5 |
>>> oh? I can pipe that output into cat or any any daemon I like? Doesn't |
6 |
>>> look like so. |
7 |
>> |
8 |
>> But it does, you can "cat" with journalctl; it's one of its output |
9 |
>> options: |
10 |
>> |
11 |
>> -o, --output= |
12 |
>> cat |
13 |
>> generates a very terse output only showing the actual |
14 |
>> message of each journal entry with no meta data, not even a timestamp. |
15 |
> |
16 |
> As I do not have systemd installed on any machine, I can't check the |
17 |
> man-pages. |
18 |
|
19 |
They are online [1]. |
20 |
|
21 |
> But, if that is the only method to get parseable text from journalctl, |
22 |
> then that is less then useless. |
23 |
|
24 |
I only put that option as tongue-in-cheek, since someone complained |
25 |
about not being able to "cat" the logs. Many more options are |
26 |
available. |
27 |
|
28 |
> I would expect an export option providing the same detail level as I |
29 |
> currently find in /var/log/messages. |
30 |
> A timestamp is a minimum required for logging system output. |
31 |
|
32 |
Everybody agrees with that; that's why the journal supports a lot of |
33 |
formatting options. From [2]: |
34 |
|
35 |
-o, --output= |
36 |
Controls the formatting of the journal entries that are |
37 |
shown. Takes one of the following options: |
38 |
|
39 |
short |
40 |
is the default and generates an output that is mostly |
41 |
identical to the formatting of classic syslog files, showing one line |
42 |
per journal entry. |
43 |
|
44 |
short-iso |
45 |
is very similar, but shows ISO 8601 wallclock timestamps. |
46 |
|
47 |
short-precise |
48 |
is very similar, but shows timestamps with full |
49 |
microsecond precision. |
50 |
|
51 |
short-monotonic |
52 |
is very similar, but shows monotonic timestamps instead |
53 |
of wallclock timestamps. |
54 |
|
55 |
verbose |
56 |
shows the full-structured entry items with all fields. |
57 |
|
58 |
export |
59 |
serializes the journal into a binary (but mostly |
60 |
text-based) stream suitable for backups and network transfer (see |
61 |
Journal Export Format[1] for more information). |
62 |
|
63 |
json |
64 |
formats entries as JSON data structures, one per line |
65 |
(see Journal JSON Format[2] for more information). |
66 |
|
67 |
json-pretty |
68 |
formats entries as JSON data structures, but formats |
69 |
them in multiple lines in order to make them more readable for humans. |
70 |
|
71 |
json-sse |
72 |
formats entries as JSON data structures, but wraps them |
73 |
in a format suitable for Server-Sent Events[3]. |
74 |
|
75 |
cat |
76 |
generates a very terse output only showing the actual |
77 |
message of each journal entry with no meta data, not even a timestamp. |
78 |
|
79 |
|
80 |
So you can have the default; journalctl -b | head: |
81 |
|
82 |
-- Logs begin at Tue 2013-09-24 13:39:03 CDT, end at Tue 2014-02-18 |
83 |
08:28:44 CST. -- |
84 |
Feb 10 09:50:37 centurion systemd-journal[371]: Runtime journal is |
85 |
using 712.0K (max 198.0M, leaving 297.1M of free 1.9G, current limit |
86 |
198.0M). |
87 |
Feb 10 09:50:37 centurion systemd-journal[371]: Runtime journal is |
88 |
using 716.0K (max 198.0M, leaving 297.1M of free 1.9G, current limit |
89 |
198.0M). |
90 |
Feb 10 09:50:37 centurion systemd-journal[371]: Journal started |
91 |
Feb 10 09:50:37 centurion systemd-modules-load[370]: Inserted module 'fuse' |
92 |
Feb 10 09:50:37 centurion systemd[1]: Starting Swap. |
93 |
Feb 10 09:50:37 centurion systemd[1]: Reached target Swap. |
94 |
Feb 10 09:50:37 centurion systemd-modules-load[370]: Inserted module 'kvm_intel' |
95 |
Feb 10 09:50:37 centurion systemd[1]: Starting Local File Systems. |
96 |
Feb 10 09:50:37 centurion systemd-journal[371]: Missed 107 kernel messages |
97 |
|
98 |
(The -b option shows the logs from the current boot; you can get the |
99 |
previous one with -b -1, the one before with -b -2, etc.) |
100 |
|
101 |
You can have short; journalctl -b -o short | head, which for the first |
102 |
lines of my current boot look the same as the default. You can have |
103 |
ISO timestamps; journalctl -b -o short-iso: |
104 |
|
105 |
-- Logs begin at Tue 2013-09-24 13:39:03 CDT, end at Tue 2014-02-18 |
106 |
08:31:54 CST. -- |
107 |
2014-02-10T09:50:37-0600 centurion systemd-journal[371]: Runtime |
108 |
journal is using 712.0K (max 198.0M, leaving 297.1M of free 1.9G, |
109 |
current limit 198.0M). |
110 |
2014-02-10T09:50:37-0600 centurion systemd-journal[371]: Runtime |
111 |
journal is using 716.0K (max 198.0M, leaving 297.1M of free 1.9G, |
112 |
current limit 198.0M). |
113 |
2014-02-10T09:50:37-0600 centurion systemd-journal[371]: Journal started |
114 |
2014-02-10T09:50:37-0600 centurion systemd-modules-load[370]: Inserted |
115 |
module 'fuse' |
116 |
2014-02-10T09:50:37-0600 centurion systemd[1]: Starting Swap. |
117 |
2014-02-10T09:50:37-0600 centurion systemd[1]: Reached target Swap. |
118 |
2014-02-10T09:50:37-0600 centurion systemd-modules-load[370]: Inserted |
119 |
module 'kvm_intel' |
120 |
2014-02-10T09:50:37-0600 centurion systemd[1]: Starting Local File Systems. |
121 |
2014-02-10T09:50:37-0600 centurion systemd-journal[371]: Missed 107 |
122 |
kernel messages |
123 |
|
124 |
You can have nanosecond precision; journalctl -b -o short-precise | head: |
125 |
|
126 |
-- Logs begin at Tue 2013-09-24 13:39:03 CDT, end at Tue 2014-02-18 |
127 |
08:31:54 CST. -- |
128 |
Feb 10 09:50:37.689600 centurion systemd-journal[371]: Runtime journal |
129 |
is using 712.0K (max 198.0M, leaving 297.1M of free 1.9G, current |
130 |
limit 198.0M). |
131 |
Feb 10 09:50:37.689910 centurion systemd-journal[371]: Runtime journal |
132 |
is using 716.0K (max 198.0M, leaving 297.1M of free 1.9G, current |
133 |
limit 198.0M). |
134 |
Feb 10 09:50:37.690139 centurion systemd-journal[371]: Journal started |
135 |
Feb 10 09:50:37.690184 centurion systemd-modules-load[370]: Inserted |
136 |
module 'fuse' |
137 |
Feb 10 09:50:37.689866 centurion systemd[1]: Starting Swap. |
138 |
Feb 10 09:50:37.689902 centurion systemd[1]: Reached target Swap. |
139 |
Feb 10 09:50:37.689982 centurion systemd-modules-load[370]: Inserted |
140 |
module 'kvm_intel' |
141 |
Feb 10 09:50:37.690419 centurion systemd[1]: Starting Local File Systems. |
142 |
Feb 10 09:50:37.692022 centurion systemd-journal[371]: Missed 107 |
143 |
kernel messages |
144 |
|
145 |
You can have monotonic timestamps; journalctl -b -o short-monotonic | head: |
146 |
|
147 |
-- Logs begin at Tue 2013-09-24 13:39:03 CDT, end at Tue 2014-02-18 |
148 |
08:32:44 CST. -- |
149 |
[ 0.568295] centurion systemd-journal[371]: Runtime journal is |
150 |
using 712.0K (max 198.0M, leaving 297.1M of free 1.9G, current limit |
151 |
198.0M). |
152 |
[ 0.568605] centurion systemd-journal[371]: Runtime journal is |
153 |
using 716.0K (max 198.0M, leaving 297.1M of free 1.9G, current limit |
154 |
198.0M). |
155 |
[ 0.568834] centurion systemd-journal[371]: Journal started |
156 |
[ 0.569202] centurion systemd-modules-load[370]: Inserted module 'fuse' |
157 |
[ 0.569530] centurion systemd[1]: Starting Swap. |
158 |
[ 0.569823] centurion systemd[1]: Reached target Swap. |
159 |
[ 0.570157] centurion systemd-modules-load[370]: Inserted module 'kvm_intel' |
160 |
[ 0.570452] centurion systemd[1]: Starting Local File Systems. |
161 |
[ 0.570718] centurion systemd-journal[371]: Missed 107 kernel messages |
162 |
|
163 |
You can get it formatted with JSON; journalctl -b -o json | head -n 3: |
164 |
|
165 |
{ "__CURSOR" : "s=12a9a4b1107f4a1e8219c6f392b59998;i=577;b=85b3bd9a292b40da80a73aac41f06840;m=8abe7;t=4f20f4d08b300;x=ac5d8ecfe215e10f", |
166 |
"__REALTIME_TIMESTAMP" : "1392047437689600", "__MONOTONIC_TIMESTAMP" : |
167 |
"568295", "_BOOT_ID" : "85b3bd9a292b40da80a73aac41f06840", "PRIORITY" |
168 |
: "6", "_TRANSPORT" : "driver", "MESSAGE" : "Runtime journal is using |
169 |
712.0K (max 198.0M, leaving 297.1M of free 1.9G, current limit |
170 |
198.0M).", "MESSAGE_ID" : "ec387f577b844b8fa948f33cad9a75e6", "_PID" : |
171 |
"371", "_UID" : "0", "_GID" : "0", "_COMM" : "systemd-journal", "_EXE" |
172 |
: "/usr/lib64/systemd/systemd-journald", "_CMDLINE" : |
173 |
"/usr/lib/systemd/systemd-journald", "_CAP_EFFECTIVE" : "4402800cf", |
174 |
"_SYSTEMD_CGROUP" : "/system.slice/systemd-journald.service", |
175 |
"_SYSTEMD_UNIT" : "systemd-journald.service", "_SYSTEMD_SLICE" : |
176 |
"system.slice", "_MACHINE_ID" : "386846e50fae217775d8d80045a18054", |
177 |
"_HOSTNAME" : "centurion" } |
178 |
{ "__CURSOR" : "s=12a9a4b1107f4a1e8219c6f392b59998;i=578;b=85b3bd9a292b40da80a73aac41f06840;m=8ad1d;t=4f20f4d08b436;x=5d13a456b0fc099a", |
179 |
"__REALTIME_TIMESTAMP" : "1392047437689910", "__MONOTONIC_TIMESTAMP" : |
180 |
"568605", "_BOOT_ID" : "85b3bd9a292b40da80a73aac41f06840", "PRIORITY" |
181 |
: "6", "_TRANSPORT" : "driver", "MESSAGE_ID" : |
182 |
"ec387f577b844b8fa948f33cad9a75e6", "_PID" : "371", "_UID" : "0", |
183 |
"_GID" : "0", "_COMM" : "systemd-journal", "_EXE" : |
184 |
"/usr/lib64/systemd/systemd-journald", "_CMDLINE" : |
185 |
"/usr/lib/systemd/systemd-journald", "_CAP_EFFECTIVE" : "4402800cf", |
186 |
"_SYSTEMD_CGROUP" : "/system.slice/systemd-journald.service", |
187 |
"_SYSTEMD_UNIT" : "systemd-journald.service", "_SYSTEMD_SLICE" : |
188 |
"system.slice", "_MACHINE_ID" : "386846e50fae217775d8d80045a18054", |
189 |
"_HOSTNAME" : "centurion", "MESSAGE" : "Runtime journal is using |
190 |
716.0K (max 198.0M, leaving 297.1M of free 1.9G, current limit |
191 |
198.0M)." } |
192 |
{ "__CURSOR" : "s=12a9a4b1107f4a1e8219c6f392b59998;i=579;b=85b3bd9a292b40da80a73aac41f06840;m=8ae02;t=4f20f4d08b51b;x=656aa8fa8583d9dd", |
193 |
"__REALTIME_TIMESTAMP" : "1392047437690139", "__MONOTONIC_TIMESTAMP" : |
194 |
"568834", "_BOOT_ID" : "85b3bd9a292b40da80a73aac41f06840", "PRIORITY" |
195 |
: "6", "_TRANSPORT" : "driver", "_PID" : "371", "_UID" : "0", "_GID" : |
196 |
"0", "_COMM" : "systemd-journal", "_EXE" : |
197 |
"/usr/lib64/systemd/systemd-journald", "_CMDLINE" : |
198 |
"/usr/lib/systemd/systemd-journald", "_CAP_EFFECTIVE" : "4402800cf", |
199 |
"_SYSTEMD_CGROUP" : "/system.slice/systemd-journald.service", |
200 |
"_SYSTEMD_UNIT" : "systemd-journald.service", "_SYSTEMD_SLICE" : |
201 |
"system.slice", "_MACHINE_ID" : "386846e50fae217775d8d80045a18054", |
202 |
"_HOSTNAME" : "centurion", "MESSAGE" : "Journal started", "MESSAGE_ID" |
203 |
: "f77379a8490b408bbe5f6940505a777b" } |
204 |
|
205 |
Or pretty JSON; journalctl -b -o json-pretty | head -n 22: |
206 |
|
207 |
{ |
208 |
"__CURSOR" : |
209 |
"s=12a9a4b1107f4a1e8219c6f392b59998;i=577;b=85b3bd9a292b40da80a73aac41f06840;m=8abe7;t=4f20f4d08b300;x=ac5d8ecfe215e10f", |
210 |
"__REALTIME_TIMESTAMP" : "1392047437689600", |
211 |
"__MONOTONIC_TIMESTAMP" : "568295", |
212 |
"_BOOT_ID" : "85b3bd9a292b40da80a73aac41f06840", |
213 |
"PRIORITY" : "6", |
214 |
"_TRANSPORT" : "driver", |
215 |
"MESSAGE" : "Runtime journal is using 712.0K (max 198.0M, |
216 |
leaving 297.1M of free 1.9G, current limit 198.0M).", |
217 |
"MESSAGE_ID" : "ec387f577b844b8fa948f33cad9a75e6", |
218 |
"_PID" : "371", |
219 |
"_UID" : "0", |
220 |
"_GID" : "0", |
221 |
"_COMM" : "systemd-journal", |
222 |
"_EXE" : "/usr/lib64/systemd/systemd-journald", |
223 |
"_CMDLINE" : "/usr/lib/systemd/systemd-journald", |
224 |
"_CAP_EFFECTIVE" : "4402800cf", |
225 |
"_SYSTEMD_CGROUP" : "/system.slice/systemd-journald.service", |
226 |
"_SYSTEMD_UNIT" : "systemd-journald.service", |
227 |
"_SYSTEMD_SLICE" : "system.slice", |
228 |
"_MACHINE_ID" : "386846e50fae217775d8d80045a18054", |
229 |
"_HOSTNAME" : "centurion" |
230 |
} |
231 |
|
232 |
See if you can easily do that with rsyslog or syslog-ng. |
233 |
|
234 |
Regards. |
235 |
|
236 |
[1] http://www.freedesktop.org/software/systemd/man/ |
237 |
[2] http://www.freedesktop.org/software/systemd/man/journalctl.html |
238 |
|
239 |
Regards. |
240 |
-- |
241 |
Canek Peláez Valdés |
242 |
Posgrado en Ciencia e Ingeniería de la Computación |
243 |
Universidad Nacional Autónoma de México |