Commit graph

191 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 08f105df24 analyze: fix formatting of timestamps with 0 µs
There is a rule that "%.0d" formats 0 as "". There is no such rule for
"%0d" and 0 :(. The output had an extra 0 if usec was 0.
2019-07-15 19:11:16 +02:00
Yu Watanabe af2d6d477c analyze: format output of 'systemd-analyze timestamp' by using Table 2019-07-16 01:14:20 +09:00
Yu Watanabe 7503c6e80e analyze: format output of 'systemd-analyze timespan' by using Table 2019-07-16 01:07:31 +09:00
Yu Watanabe 9c712cf285 analyze: format output of 'systemd-analyze calendar' by using Table 2019-07-16 00:46:10 +09:00
Yu Watanabe d8bfdbe1fa analyze: format output of 'systemd-analyze blame' by using Table 2019-07-16 00:19:59 +09:00
Zbigniew Jędrzejewski-Szmek 1f65fd4926 basic/time-util: add helper function to check if timestamp is set
No functional change.
2019-07-04 19:12:47 +02:00
Zbigniew Jędrzejewski-Szmek edfea9fe0d analyze: add 'condition' verb
We didn't have a straightforward way to parse and evaluate those strings.
Prompted by #12881.
2019-06-27 10:54:37 +02:00
Zbigniew Jędrzejewski-Szmek ea62aa24ae analyze: also print unix time in "timestamp" 2019-05-21 09:56:41 +02:00
Zbigniew Jędrzejewski-Szmek c269607f9b analyze: give a hint about calendar/timestamp/timespan use
This should help clear up the confusion in
https://bugzilla.redhat.com/show_bug.cgi?id=1711065.
2019-05-21 09:56:41 +02:00
Zbigniew Jędrzejewski-Szmek 2cae4711f3 analyze: add 'timestamp' verb
We had 'calendar' and 'timespan', but the third one was missing.
Also consistently order the verbs as calendar/timestamp/timespan in help.

The output from 'timespan' is highlighted more.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1711065.
2019-05-17 10:09:32 +02:00
Zbigniew Jędrzejewski-Szmek b99f4d484b analyze: drop redundant call to calendar_spec_normalize()
calendar_spec_from_string() already does that.
2019-05-16 23:14:41 +02:00
Yu Watanabe 80a8a7fb20 analyze: fix help message 2019-05-15 15:09:45 +02:00
Zbigniew Jędrzejewski-Szmek 1a04395959 Enable log colors for most of tools in /usr/bin
When emitting the calendarspec warning we want to see some color.
Follow-up for 04220fda5c.

Exceptions:
- systemctl, because it has a lot hand-crafted coloring
- tmpfiles, sysusers, stdio-bridge, etc, because they are also used in
  services and I'm not sure if this wouldn't mess up something.
2019-05-08 09:50:21 +02:00
Sebastian Jennen 1ace223ca7 code style format: clang-format applied to src/a*/*
[zj: this is a subset of changes generated by clang-format, just the ones
  I think improve readability or consistency.]

This is a part of https://github.com/systemd/systemd/pull/11811.
2019-04-12 17:26:33 +02:00
Lennart Poettering 196f306795 analyze: check both possible mount points of tracefs
Let's try the new one first, the old one second.
2019-03-29 14:57:37 +01:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
This means we need to include many more headers in various files that simply
included util.h before, but it seems cleaner to do it this way.
2019-03-27 11:53:12 +01:00
Zbigniew Jędrzejewski-Szmek 2fffb93b32 analyze: reword explanation in critical-chain header
Let's try to make it a bit clearer.
2019-03-15 10:17:46 +01:00
Lennart Poettering d8b4d14df4 util: split out nulstr related stuff to nulstr-util.[ch] 2019-03-14 13:25:52 +01:00
Lennart Poettering 760877e90c util: split out sorting related calls to new sort-util.[ch] 2019-03-13 12:16:43 +01:00
Zbigniew Jędrzejewski-Szmek deed4d50a2 analyze: add color highlighting when printing calendar elapses
With multiple iterations, I found it hard to pick out the interesting bits in
the column of text. I tried plain highlighting first, but it doesn't seem
enough. But blue/yellow makes it easy to jump to the right iteration.
2019-02-22 09:32:17 +01:00
Zbigniew Jędrzejewski-Szmek 84653d99fa analyze: split out loop innards into a separate function
This was intended to be just a refactoring, but it also fixes a minor bug:
after printing "never", we would skip subsequent expressions:

$ systemd-analyze calendar --iterations=20 @0 @1
systemd-analyze calendar --iterations=20 @0 @1
  Original form: @0
Normalized form: 1970-01-01 00:00:00 UTC
    Next elapse: never

(the second expression was skipped).
2019-02-22 09:32:17 +01:00
Lennart Poettering f2ccf8320a analyze: optionally, show more than one elapse time for calendar expressions 2019-02-22 09:10:54 +01:00
Zbigniew Jędrzejewski-Szmek f1d9d36ac5 analyze: generalize cat-config to apply to tmpfiles, presets, hwdb.d, etc.
Fixes #10256.

What works:

systemd-analyze cat-config systemd/system-preset
systemd-analyze cat-config systemd/user-preset
systemd-analyze cat-config tmpfiles.d
systemd-analyze cat-config sysusers.d
systemd-analyze cat-config systemd/sleep.conf
systemd-analyze cat-config systemd/user.conf
systemd-analyze cat-config systemd/system.conf
systemd-analyze cat-config udev/udev.conf
(and other .conf files)
systemd-analyze cat-config udev/rules.d
systemd-analyze cat-config environment.d
systemd-analyze cat-config environment

Directories may be specified with the trailing dash or not.

The caveat is that for user configuration, systemd and other tools also look
at ~/.config/. It would be nice to support this, but this patch doesn't.
"cat-config --user" is rejected, and we may allow it in the future and then
extend the search path with directories under ~/.config.

What doesn't work (and probably shouldn't because those files cannot be
meaningfully concatenated):

systemd-analyze cat-config systemd/system  (.service, .slice, .socket, ...)
systemd-analyze cat-config systemd/user
systemd-analyze cat-config systemd/network (.network, .link, and .dnssd)

The hardcoding of information about paths in this manner is a bit ugly, but
OTOH, it is not too onerous, and at least we have one place where all the
schemes are "documented" through code. It'll make us think twice before adding
yet another slightly different scheme.
2019-02-18 10:29:33 +01:00
Zbigniew Jędrzejewski-Szmek c2953e0808 analyze: use SYNTHETIC_ERRNO 2019-02-18 10:29:33 +01:00
Zbigniew Jędrzejewski-Szmek 681bd2c524 meson: generate version tag from git
$ build/systemctl --version
systemd 239-3555-g6178cbb5b5
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid
$ git tag v240 -m 'v240'
$ ninja -C build
ninja: Entering directory `build'
[76/76] Linking target fuzz-unit-file.
$ build/systemctl --version
systemd 240
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid

This is very useful during development, because a precise version string is
embedded in the build product and displayed during boot, so we don't have to
guess answers for questions like "did I just boot the latest version or the one
from before?".

This change creates an overhead for "noop" builds. On my laptop, 'ninja -C
build' that does nothing goes from 0.1 to 0.5 s. It would be nice to avoid
this, but I think that <1 s is still acceptable.

Fixes #7183.

PACKAGE_VERSION is renamed to GIT_VERSION, to make it obvious that this is the
more dynamically changing version string.

Why save to a file? It would be easy to generate the version tag using
run_command(), but we want to go through a file so that stuff gets rebuilt when
this file changes. If we just defined an variable in meson, ninja wouldn't know
it needs to rebuild things.
2018-12-21 13:43:20 +01:00
Lennart Poettering 9a6f746fb6 locale-util: prefix special glyph enum values with SPECIAL_GLYPH_
This has been irritating me for quite a while: let's prefix these enum
values with a common prefix, like we do for almost all other enums.

No change in behaviour, just some renaming.
2018-12-14 08:22:54 +01:00
Lennart Poettering ec16f3b6dd analyze: add new security verb 2018-11-30 16:48:09 +01:00
Lennart Poettering 2987225ce6 analyze: use strv_skip() where appropriate 2018-11-30 16:46:09 +01:00
Lennart Poettering 0ed3da7c8c analyze: remove unnecessary negation of bus_error_message() error number parameter 2018-11-30 16:46:09 +01:00
Lennart Poettering 90bea7448d analyze: fix include order 2018-11-30 16:46:09 +01:00
Michal Koutný d3340e6f95 analyze: Fix build without seccomp (#10899) 2018-11-24 02:40:32 +09:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Yu Watanabe d665c7b2db analyze: use static destructors 2018-11-20 16:48:21 +01:00
Lennart Poettering a9bfb3eff2 analyze: add some minimal ANSI highlighting of syscall-filter output 2018-11-16 16:10:57 +01:00
Lennart Poettering cdf6258c2e analyze: show list of syscalls the kernel supports but not included in any group in the output
This is quite useful for making sure our list is complete.
2018-11-16 16:10:57 +01:00
Lennart Poettering 042cad5737
Merge pull request #10753 from keszybz/pager-no-interrupt
Add mode in journalctl where ^C is handled by the pager
2018-11-14 20:09:39 +01:00
Zbigniew Jędrzejewski-Szmek 0221d68a13 basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
2018-11-14 16:25:11 +01:00
Yu Watanabe 20a51f6a26 id128,analyze: fix layout of help message 2018-11-10 11:58:50 +01:00
Chris Down 3f1c1287a9 analyze: Add "timespan" command to dump time span in usec
This is useful for a couple of cases, I'm mostly interested in case #1:

1. Verifying "reasonable" values in a trivially scriptable way
2. Debugging unexpected time span parsing directly

Test Plan:

```
% build/systemd-analyze timespan 20
Original: 20
      μs: 20
   Human: 20us
% build/systemd-analyze timespan 20ms
Original: 20ms
      μs: 20000
   Human: 20ms
% build/systemd-analyze timespan 20z
Failed to parse time span '20z': Invalid argument
```
2018-10-23 14:26:51 +02:00
Lennart Poettering 41159592f8
Merge pull request #10470 from yuwata/log-message-updates
Log message updates
2018-10-19 22:58:53 +02:00
Yu Watanabe 14cb109d45 tree-wide: replace 'unsigned int' with 'unsigned' 2018-10-19 22:19:12 +02:00
Yu Watanabe 0c7539634f analyze: include error cause in the log message 2018-10-20 00:46:33 +09:00
Yu Watanabe 93bab28895 tree-wide: use typesafe_qsort() 2018-09-19 08:02:52 +09:00
Zbigniew Jędrzejewski-Szmek b5d6f7ead6 analyze: use temporary var to simplify code 2018-08-23 11:30:57 +02:00
Zbigniew Jędrzejewski-Szmek a9e241dcb3
Merge pull request #9801 from yuwata/analyze-cleanups
analyze: several improvements
2018-08-20 13:12:53 +02:00
Lennart Poettering 37ec0fdd34 tree-wide: add clickable man page link to all --help texts
This is a bit like the info link in most of GNU's --help texts, but we
don't do info but man pages, and we make them properly clickable on
terminal supporting that, because awesome.

I think it's generally advisable to link up our (brief) --help texts and
our (more comprehensive) man pages a bit, so this should be an easy and
straight-forward way to do it.
2018-08-20 11:33:04 +02:00
Yu Watanabe 4ae25393f3 tree-wide: shorten error logging a bit
Continuation of 4027f96aa0.
2018-08-07 10:14:33 +09:00
Kirill Marinushkin 02be0ccad2 analyze: fix condition for pretty printing kernel time
On target boards without RTC, `t->kernel_time` is 0 or 1 usec.
`systemd-analyze` reads this value over D-Bus from
`org.freedesktop.systemd1.Manager`, property `KernelTimestamp`.

The issue is: if `t->kernel_time` is 0, `systemd-analyze` does not print
the kernel time:

~~~~
$ systemd-analyze
Startup finished in 1.860s (userspace) = 5.957s
~~~~

This commit fixes the misbehaviour:

~~~~
$ systemd-analyze
Startup finished in 3.866s (kernel) + 2.015s (userspace) = 5.881s
~~~~

Fixes #7721.

v2: fixes one more condition (by Yu Watanabe <watanabe.yu+github@gmail.com>)
v3: fixes one more condition (by Kirill Marinushkin <kmarinushkin@de.adit-jv.com>)
2018-08-06 23:13:53 +09:00
Yu Watanabe eddb5037f1 analyze: set reverse_offset for containerized system 2018-08-06 22:21:05 +09:00