Commit graph

171 commits

Author SHA1 Message Date
Lennart Poettering b6741478e7 journal: add ability to browse journals of running OS containers
This adds the new library call sd_journal_open_container() and a new
"-M" switch to journalctl. Particular care is taken that journalctl's
"-b" switch resolves to the current boot ID of the container, not the
host.
2013-12-11 22:04:03 +01:00
Zbigniew Jędrzejewski-Szmek 2b6bf07dd2 Get rid of our reimplementation of basename
The only problem is that libgen.h #defines basename to point to it's
own broken implementation instead of the GNU one. This can be fixed
by #undefining basename.
2013-12-06 21:29:55 -05:00
Karel Zak 4561be3a64 Remove duplicate includes 2013-11-18 20:28:55 -05:00
Lennart Poettering eb9da376d7 clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
2013-11-06 18:28:39 +01:00
Zbigniew Jędrzejewski-Szmek f11880744c journalctl: add --list-boots to show boot IDs and times
Suggested by David Wilkins <dwilkins@maths.tcd.ie> in
https://bugzilla.redhat.com/show_bug.cgi?id=967521:

> [Specific boot ID is a] bit of a palaver to obtain.  I consulted the
> verbose dump of the journal to discover the _BOOT_ID for the
> timestamp, and then generated the journal dump for that boot using
> journalctl _BOOT_ID=foo -o short-monotonic.
2013-10-28 23:43:57 -04:00
Zbigniew Jędrzejewski-Szmek 7ff7394d9e Never call qsort on potentially NULL arrays
This extends 62678ded 'efi: never call qsort on potentially
NULL arrays' to all other places where qsort is used and it
is not obvious that the count is non-zero.
2013-10-13 17:56:54 -04:00
Zbigniew Jędrzejewski-Szmek 2b8f6883a1 journalctl: flip to --full by default
We already shew lines in full when using a pager or not on a
tty. The commit disables ellipsization in the sole remaining case,
namely when --follow is used.

This has been a popular request for a long time, and indeed, full
output seems much more useful. Old behaviour can still be requested by
using --no-full. Old options retain their behaviour for compatiblity,
but aren't advertised as much. This change applies only to jornalctl,
not to systemctl, when ellipsization is useful to keep the layout.

https://bugzilla.redhat.com/show_bug.cgi?id=984758
2013-10-07 23:41:05 -04:00
Zbigniew Jędrzejewski-Szmek 289f910e16 journald: be a bit more verbose when vacuuming
Vacuuming behaviour is a bit confusing, and/or we have some bugs,
so those additional messages should help to find out what's going
on. Also, rotation of journal files shouldn't be happening too
often, so the level of the messages is bumped to info, so that
they'll be logged under normal operation.
2013-09-10 08:27:30 -04:00
Zbigniew Jędrzejewski-Szmek f02d836794 logs-show: add short-precise mode with us timestamps
Also, always show us timestamps in verbose mode.

https://bugzilla.redhat.com/show_bug.cgi?id=991678
2013-08-20 21:18:43 -04:00
Zbigniew Jędrzejewski-Szmek 94e0bd7db1 systemctl: show hint about --full when lines don't fit 2013-08-11 18:10:34 -04:00
Daniel Schaal 0b5a519c89 systemd-delta: Only print colors when on a tty
This make systemd-delta follow the behaviour of systemctl
and journalctl.

https://bugs.freedesktop.org/show_bug.cgi?id=67656

[zj: unify color query methods between those three programs.]
2013-08-04 08:33:02 -04:00
Zbigniew Jędrzejewski-Szmek 68fee104e6 journalctl: use _COMM= match for scripts
In case of scripts, _EXE is set to the interpreter name, and
_COMM is set based on the file name. Add a match for _COMM,
and _EXE if the interpreter is not a link (e.g. for yum,
the interpreter is /usr/bin/python, but it is a link to
/usr/bin/python2, which in turn is a link to /usr/bin/python2.7,
at least on Fedora, so we end up with _EXE=/usr/bin/python2.7).
I don't think that such link chasing makes sense, because
the final _EXE name is more likely to change.
2013-07-26 12:16:57 -04:00
Tomasz Torcz 44bc6e1fe0 journalctl: add ”short-iso” output format with verbose ISO8601 timestamps
Example:
2013-07-18T10:10:01+0200 sandworm CROND[20957]: (root) CMD (/usr/lib64/sa/sa1 1 1)
2013-07-18 15:58:49 +02:00
Zbigniew Jędrzejewski-Szmek a54e3b3d6a journalctl: fix signedness warning and boot-id syntax check 2013-07-18 08:07:08 -04:00
Zbigniew Jędrzejewski-Szmek d121b396cc journalctl: remove ":" from the --boot syntax
Instead of :-0, :1, :5, etc., use -0, 1 or +1, 5, etc. For BOOT_ID+OFFSET,
use BOOT_ID+offset or BOOT_ID-offset (either + or - is required).

Also make error handling a bit more robust and verbose.
Modify the man page to describe the most common case (-b) first,
and the second most common case (-b -1) second.
2013-07-17 23:41:10 -04:00
Zbigniew Jędrzejewski-Szmek 4ad16808c0 journalctl,systemctl: fix tiny memleak 2013-07-16 22:41:47 -04:00
Zbigniew Jędrzejewski-Szmek 248fc619b5 journalctl: augment short mode with a cursor at the end
Two options are added: --show-cursor to print the cursor at the end,
and --after-cursor to resume logs on the next line after the previous one.
2013-07-16 22:41:47 -04:00
Jan Janssen a331b5e6d4 journalctl: Add support for showing messages from a previous boot
Hi,

I redid the boot ID look up to use enumerate_unique.

This is quite fast if the cache is warm but painfully slow if
it isn't. It has a slight chance of returning the wrong order if
realtime clock jumps around.

This one has to do n searches for every boot ID there is plus
a sort, so it depends heavily on cache hotness. This is in contrast
to the other way of look-up through filtering by a MESSAGE_ID,
which only needs about 1 seek + whatever amount of relative IDs
you want to walk.

I also have a linked-list + (in-place) mergesort version of this
patch, which has pretty much the same runtime. But since this one
is using libc sorting and armortized allocation, I prefer this
one.

To summarize: The MESSAGE_ID way is a *lot* faster but can be
incomplete due to rotation, while the enumerate+sort will find
every boot ID out there but will be painfully slow for large
journals and cold caches.

You choose :P

Jan
2013-07-16 17:38:12 +02:00
Shawn Landden b8547c10c8 journalctl: add --force option to recreate FSS 2013-07-14 23:55:18 -04:00
Shawn Landden b98e3866fd journalctl: have a useful --setup-keys error message when using non-persistant logging
Generating seed...

Generating key pair...
Generating sealing key...
Failed to open /var/log/journal/33f46101703a10c5fc6fa4f451840101/fss.tmp.k2wDDU: No such file or directory
2013-07-13 07:56:11 -04:00
Daniel Albers 98a6e132b5 journalctl,loginctl,systemctl,systemd-cgls: add -l as alias for --full
https://bugs.freedesktop.org/show_bug.cgi?id=65850
2013-06-17 10:33:34 -04:00
Zbigniew Jędrzejewski-Szmek 8d98da3f11 journalctl: allow the user to specify the file(s) to use
This is useful for debugging and feels pretty natural. For example
answering the question "is this big .journal file worth keeping?"
is made easier.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek 3001c74580 journalctl: no color for --reboot-- when not on tty 2013-06-10 10:10:06 -04:00
Zbigniew Jędrzejewski-Szmek 3f3a438f58 journalctl: add --system/--user flags
--user basically gives messages from your own systemd --user services.
--system basically gives messages from PID 1, kernel, and --system
services. Those two options are not exahustive, because a priviledged
user might be able to see messages from other users, and they will not
be shown with either or both of those flags.
2013-06-10 10:10:06 -04:00
Zbigniew Jędrzejewski-Szmek a72b63536f journalctl: fix verbose output when no logs are found
$ journalctl -o verbose _EXE=/quiet/binary -f
-- Logs begin at Sun 2013-03-17 17:28:22 EDT. --
Failed to get realtime timestamp: Cannot assign requested address

JOURNAL_FOREACH_DATA_RETVAL is added, which allows the caller
to get the return value from sd_journal_enumerate_data. I think
we might want to expose this macro like SD_JOURNAL_FOREACH_DATA,
but for now it is in journal-internal.h.

There's a change in behaviour for output_*, not only in
output_verbose, that errors in sd_j_enumerate_data are not silently
ignored anymore.

https://bugs.freedesktop.org/show_bug.cgi?id=56459
2013-06-09 22:38:29 -04:00
Zbigniew Jędrzejewski-Szmek 5ec7641776 systemctl: limit logs in status to current boot
Also reworded a few debug messages for brevity, and added a log
statement which prints out the filter at debug level:

Journal filter: (((UNIT=sys-module-configfs.device AND _PID=1) OR (COREDUMP_UNIT=sys-module-configfs.device AND MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1) OR _SYSTEMD_UNIT=sys-module-configfs.device) AND _BOOT_ID=4e3c518ab0474c12ac8de7896fe6b154)
2013-06-04 09:59:06 -04:00
Zbigniew Jędrzejewski-Szmek 9927180417 journalctl: add -k/--dmesg 2013-05-14 23:08:00 -04:00
Lennart Poettering e724b0639c hostname: only suppress setting of pretty hostname if it is non-equal to the static hostname and if the static hostname is set, too
https://bugzilla.redhat.com/show_bug.cgi?id=957814
2013-05-07 20:56:41 +02:00
Harald Hoyer 7fd1b19bc9 move _cleanup_ attribute in front of the type
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18 09:11:22 +02:00
Harald Hoyer b9e405246e journalctl: specify "--unit=" and "--user-unit" multiple times
Previously only one "--unit=" or "--user-unit" could be specified.
With this patch, journalcrtl can show multiple units.

$ journalctl -u systemd-udevd.service -u sshd.service -u crond.service -b
-- Logs begin at Sa 2013-03-23 11:08:45 CET, end at Fr 2013-04-12
09:10:22 CEST. --
Apr 12 08:41:37 lenovo systemd[1]: Started udev Kernel Device Manager.
Apr 12 08:41:37 lenovo systemd[1]: Stopped udev Kernel Device Manager.
Apr 12 08:41:38 lenovo systemd[1]: Started udev Kernel Device Manager.
Apr 12 08:41:38 lenovo crond[291]: (CRON) INFO (Syslog will be used
		instead of sendmail.)
Apr 12 08:41:38 lenovo crond[291]: (CRON) INFO (running with inotify
		support)
Apr 12 08:41:39 lenovo systemd[1]: Starting OpenSSH server daemon...
Apr 12 08:41:39 lenovo systemd[1]: Started OpenSSH server daemon.
Apr 12 08:41:39 lenovo sshd[355]: Server listening on 0.0.0.0 port 22.
Apr 12 08:41:39 lenovo sshd[355]: Server listening on :: port 22.
Apr 12 08:41:39 lenovo mtp-probe[373]: checking bus 1, device 8:
"/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.6/1-1.5.6.2/1-1.5.6.2.1"
2013-04-17 09:15:23 +02:00
Harald Hoyer cd34b3c667 journal: add one more level on top with AND
When using "-p" and "-b" in combination with "-u", the output is not
what you would expect. The reason is the sd_journal_add_disjunction()
call in add_matches_for_unit() and add_matches_for_user_unit(), which
adds two ORs without taking the other conditions to every OR.

Adding another level on top with AND and sd_journal_add_conjunction()
solves the problem.

Output before:

$ journalctl -o short-monotonic -ab -p 0 -u sshd.service

-- Reboot --
[    3.216305] lenovo systemd[1]: Starting OpenSSH server daemon...
-- Reboot --
[    3.168666] lenovo systemd[1]: Starting OpenSSH server daemon...
[    3.169639] lenovo systemd[1]: Started OpenSSH server daemon.
[36285.635389] lenovo systemd[1]: Stopped OpenSSH server daemon.
-- Reboot --
[   10.838657] lenovo systemd[1]: Starting OpenSSH server daemon...
[   10.913698] lenovo systemd[1]: Started OpenSSH server daemon.
[ 6881.035183] lenovo systemd[1]: Stopped OpenSSH server daemon.
-- Reboot --
[    6.636228] lenovo systemd[1]: Starting OpenSSH server daemon...
[    6.662573] lenovo systemd[1]: Started OpenSSH server daemon.
[    6.681148] lenovo sshd[397]: Server listening on 0.0.0.0 port 22.
[    6.681379] lenovo sshd[397]: Server listening on :: port 22.

As we see, the output is from _every_ boot and priority 0 is not taken
into account.

Output after patch:

$ journalctl -o short-monotonic -ab -p 0 -u sshd.service
-- Logs begin at Sun 2013-02-24 20:54:44 CET, end at Tue 2013-03-19 14:58:21 CET. --

Increasing the priority:

$ journalctl -o short-monotonic -ab -p 6 -u sshd.service
-- Logs begin at Sun 2013-02-24 20:54:44 CET, end at Tue 2013-03-19 14:59:12 CET. --
[    6.636228] lenovo systemd[1]: Starting OpenSSH server daemon...
[    6.662573] lenovo systemd[1]: Started OpenSSH server daemon.
[    6.681148] lenovo sshd[397]: Server listening on 0.0.0.0 port 22.
[    6.681379] lenovo sshd[397]: Server listening on :: port 22.
2013-04-17 09:15:23 +02:00
Zbigniew Jędrzejewski-Szmek 21ae45930d journalctl: show fields requested with --field in full
I see little point in silently truncating fields when
they are explictly requested. With this change e.g.
  journalctl -b MESSAGE_ID=9f26aa562cf440c2b16c773d0479b518 --field=BOOTCHART
works as expected.
2013-04-17 00:09:16 -04:00
Lukas Nykryn 3a819b1b62 journalctl: check return of strjoin 2013-04-10 18:59:42 -04:00
Lennart Poettering ee531d949c journal: add public API call sd_journal_get_events()
This function should be used when filling in "struct pollfd"'s .events
field for watching the journal. It will always return POLLIN for now,
but we should keep our options open to change this later on.

This mimics libsystemd-bus' sd_bus_get_events() call with the same
purpose.
2013-04-04 17:22:28 +02:00
Lennart Poettering 2fa4092c28 util: make time formatting a bit smarter
Instead of outputting "5h 55s 50ms 3us" we'll now output "5h
55.050003s". Also, while outputting the accuracy is configurable.

Basically we now try use "dot notation" for all time values > 1min. For
>= 1s we use 's' as unit, otherwise for >= 1ms we use 'ms' as unit, and
finally 'us'.

This should give reasonably values in most cases.
2013-04-04 02:56:56 +02:00
Lennart Poettering 7f602784de util: rename parse_usec() to parse_sec() sinds the default unit is seconds
Internally we store all time values in usec_t, however parse_usec()
actually was used mostly to parse values in seconds (unless explicit
units were specified to define a different unit). Hence, be clear about
this and name the function about what we pass into it, not what we get
out of it.
2013-04-03 20:12:57 +02:00
Zbigniew Jędrzejewski-Szmek fb93cf7375 journalctl: reword error message
Sentence seemed to suggest that all three conditions must be true.
2013-03-31 19:01:57 -04:00
Zbigniew Jędrzejewski-Szmek 0db809489f journalctl: fix --update-catalog with not --root arg
grawity> `journalctl --update-catalog` from latest git prints:
         "Recursive mkdir .: Invalid argument" and
         "Failed to write : Invalid argument"
2013-03-29 10:12:41 -04:00
Zbigniew Jędrzejewski-Szmek 13cbf3a5f0 journalctl: support --root for message catalogs 2013-03-28 23:45:59 -04:00
Zbigniew Jędrzejewski-Szmek 844ec79b3c catalog: open up catalog internals
In order to write tests for the catalog functions, they
are made non-static and start taking a 'database' parameter,
which is the name of a file with the preprocessed catalog
entries.

This makes it possible to make test-catalog part of the
normal test suite, since it now only operates on files
in /tmp.

Some more tests are added.
2013-03-28 23:45:59 -04:00
Lennart Poettering 3ac251b81a journalctl: various fixes to the access check logic
- Reword messages a bit

- Correct check whether EACCES is in the set of errors

- Don't complain if no journal files are found

- allocate Set object for errors lazily since in the best case we don't
  need it at all.

- don't consider it an error if /run/log/journal doesn't exist (because
  that's the usual case actually, if storage is enabled)
2013-03-23 01:12:22 +01:00
Zbigniew Jędrzejewski-Szmek 6fe391c56d journalctl: be smarter about journal error checks
There are many ways in which we can get those checks wrong, so it is
better to warn and then error out on a real access failure.

The error messages are wrapped to <80 lines, because their primary
use is to be displayed in the terminal, and it is easier to read them
this way. Reading them in the journal can be a bit trickier, but
this is a bug in logs-show.c.
2013-03-22 15:31:45 -04:00
Zbigniew Jędrzejewski-Szmek 478c82693c build-sys: move acl searching code into libsystemd-acl
This loop over acls is a bit too much to keep inside
of another loop.
2013-03-22 15:31:45 -04:00
Lennart Poettering 4468addca6 journalctl: give a nice hint about group membership based on ACLs of /var/log/journal
If we notice that we unprivileged and not in any of the groups which
have access to /var/log/journal, print a nice message about which groups
do.

This checks and prints all groups that are in the default ACL for
/var/log/journal, which is not necessarily correct for all journal
files, but pretty close.
2013-03-22 17:44:19 +01:00
Zbigniew Jędrzejewski-Szmek 4750fade13 Remove some unused variables 2013-03-20 19:16:01 -04:00
Zbigniew Jędrzejewski-Szmek 54b7254c1f journalct: beef up entry listing
The ability to dump catalog entries in full and by id is added.
2013-03-19 21:50:43 -04:00
Zbigniew Jędrzejewski-Szmek 52aeb63cff journalctl: use _cleanup_ in one function 2013-03-19 21:50:42 -04:00
Zbigniew Jędrzejewski-Szmek 763c7aa288 journal,shared: add _cleanup_journal_close_ 2013-03-18 19:49:30 -04:00
Zbigniew Jędrzejewski-Szmek 7199aa96ce journalctl: show systemd messages about unit for -u
journalctl -u unit is not very useful, because it doesn't show
systemd messages about starting, stopping, coredumps, etc,
like systemctl status unit does. Make it show the same
information using the same rules.

If somebody really want to see just messages from by the unit,
it is easy enough to use _SYSTEMD_UNIT=...
2013-03-13 19:53:45 -04:00
Lennart Poettering fe59e38bef journalctl: imply -n1000 when -e is used
Make sure the pager does not have to buffer an unbounded number of log
messages, by default.
2013-03-07 21:49:12 +01:00