Commit graph

194 commits

Author SHA1 Message Date
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Jan Janssen 4838248766 journalctl: Allow to disable line cap with --lines=all 2014-08-31 09:18:44 -04:00
Harald Hoyer 730836403a journalctl: add "-t --identifier=STRING" option
This turns journalctl to the counterpart of systemd-cat.
Messages sent with

systemd-cat --identifier foo --prioritiy debug

can now be shown with

journalctl --identifier foo --prioritiy debug

"--identifier" is not merged with "--unit" to make a clear
distinction between syslog and systemd units.
syslog identifiers can be chosen freely by anyone.
2014-08-21 14:16:29 +02:00
Zbigniew Jędrzejewski-Szmek 601185b43d Unify parse_argv style
getopt is usually good at printing out a nice error message when
commandline options are invalid. It distinguishes between an unknown
option and a known option with a missing arg. It is better to let it
do its job and not use opterr=0 unless we actually want to suppress
messages. So remove opterr=0 in the few places where it wasn't really
useful.

When an error in options is encountered, we should not print a lengthy
help() and overwhelm the user, when we know precisely what is wrong
with the commandline. In addition, since help() prints to stdout, it
should not be used except when requested with -h or --help.

Also, simplify things here and there.
2014-08-03 21:46:07 -04:00
Zbigniew Jędrzejewski-Szmek 73f860db98 Always prefer our headers to system headers
In practice this shouldn't make much difference, but
sometimes our headers might be newer, and we want to
test them.
2014-07-31 08:56:03 -04:00
Zbigniew Jędrzejewski-Szmek 0c6ea3a4e2 Add utility function to append root to path 2014-07-26 15:08:42 -04:00
Karel Zak 7de80bfe2e Always check asprintf return code
There is a small number of the places in sources where we don't check
asprintf() return code and assume that after error the function
returns NULL pointer via the first argument. That's wrong, after
error the content of pointer is undefined.
2014-07-26 15:08:41 -04:00
Zbigniew Jędrzejewski-Szmek 4e60294351 journalctl,man: allow + only between terms
https://bugzilla.redhat.com/show_bug.cgi?id=1110712
2014-07-19 21:13:08 -04:00
Zbigniew Jędrzejewski-Szmek eacbb4d33e journal-upload: use journal as the source 2014-07-15 22:23:48 -04:00
Zbigniew Jędrzejewski-Szmek a36b8debe6 journalctl: free arg_file on exit 2014-04-05 00:41:35 -04:00
Lennart Poettering 03e334a1c7 util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:

        fd = safe_close(fd);

Which will close an fd if it is open, and reset the fd variable
correctly.

By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards.
2014-03-18 19:31:34 +01:00
Zbigniew Jędrzejewski-Szmek 0b6b7c2004 journalctl: refuse extra arguments with --verify and similar
Positional arguments only make sense with the default action.
For other actions, complain instead of ignoring them silently.
2014-02-27 00:43:24 -05:00
Lennart Poettering 39883f622f make gcc shut up
If -flto is used then gcc will generate a lot more warnings than before,
among them a number of use-without-initialization warnings. Most of them
without are false positives, but let's make them go away, because it
doesn't really matter.
2014-02-19 17:53:50 +01:00
Jan Engelhardt 73e231abde doc: update punctuation
Resolve spotted issues related to missing or extraneous commas, dashes.
2014-02-17 19:03:07 -05:00
Lennart Poettering 2d5bdf5bc0 always use the same code for creating temporary files
Let's unify our code here, and also always specifiy O_CLOEXEC.
2014-01-28 13:47:35 +01:00
Zbigniew Jędrzejewski-Szmek ea18a4b57e journalctl: allow globbing in --unit and --user-unit
This is a continuation of e3e0314b systemctl: allow globbing in commands
which take multiple unit names.

Multiple patterns can be specified, as separate arguments, or as one argument
with patterns seperated by commas.

If patterns are given, at least one unit must be matched (by any of the patterns).
This is different behaviour than systemctl, but here it is necessary because
otherwise anything would be matched, which is unlikely to be the intended
behaviour.

https://bugs.freedesktop.org/show_bug.cgi?id=59336
2014-01-11 10:07:22 -05:00
Zbigniew Jędrzejewski-Szmek f78e6385dc Use enums to make it obvious what boolean params mean
Suggested-by: Russ Allbery <rra@debian.org>
2013-12-26 15:49:54 -05:00
Zbigniew Jędrzejewski-Szmek e3e0314b56 systemctl: allow globbing in commands which take multiple unit names 2013-12-26 13:24:36 -05:00
Lennart Poettering 442e2def79 journalctl: make sure -b --foobar cannot be misunderstood as --boot=--foobar 2013-12-26 01:53:07 +01:00
Lennart Poettering 6cebe83cfa Revert "journalctl: remove unexpected behavior of journalctl -b"
This reverts commit cf5bccc2bb.

We should fix thinks properly if they aren't perfect, not just break
other things...
2013-12-26 01:52:45 +01:00
Dave Reisner cf5bccc2bb journalctl: remove unexpected behavior of journalctl -b
This flag shouldn't try and consume the following argument. It should
behave like every other flag which takes an optional argument when
parsed by getopt_long.
2013-12-25 12:39:47 -05:00
Jason St. John c736283bfb journalctl,zsh-completion: fix several issues in --help message text
-- fix grammar and reword some descriptions for clarity
-- add a useful description of what --follow does
-- fix the description for --after-cursor
-- properly introduce the FSS acronym for "Forward Secure Sealing" in
both sections
-- clarify the --disk-usage command

[zj: perform similar changes to zsh completions]

squash! journalctl: fix several issues in --help message text
2013-12-18 23:58:24 -05:00
Djalal Harouni faf5077f89 journal: pipe journalctl help output into a pager
journalctl help output might run off the screen, so be consistent
as other systemd tools do and pipe it into a pager.
2013-12-11 22:26:55 -05:00
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