Commit graph

226 commits

Author SHA1 Message Date
Lennart Poettering 0f849d0af9 analyze: fix error handling in one case 2020-08-28 18:14:53 +02:00
fangxiuning 05f7a0689e analyze: drop pointless zero initialization 2020-08-25 15:17:52 +08:00
fangxiuning ddbab78f9a bus: use bus_log_connect_error to print error message 2020-07-21 10:02:01 +09:00
Lennart Poettering 807542bece shared: split out code that maps properties to local structs
Just some refactoring, no code changes.
2020-06-30 15:09:35 +02:00
Lennart Poettering 9b71e4ab90 shared: actually move all BusLocator related calls to bus-locator.c 2020-06-30 15:09:19 +02:00
Filipe Brandenburger 41d1f469cf log: introduce log_parse_environment_cli() and log_setup_cli()
Presently, CLI utilities such as systemctl will check whether they have a tty
attached or not to decide whether to parse /proc/cmdline or EFI variable
SystemdOptions looking for systemd.log_* entries.

But this check will be misleading if these tools are being launched by a
daemon, such as a monitoring daemon or automation service that runs in
background.

Make log handling of CLI tools uniform by never checking /proc/cmdline or EFI
variables to determine the logging level.

Furthermore, introduce a new log_setup_cli() shortcut to set up common options
used by most command-line utilities.
2020-06-24 16:49:26 +02:00
Vito Caputo 5e55340ad4
Merge pull request #15681 from vcaputo/buslocator
*: switch to BusLocator-oriented helpers
2020-05-07 09:46:01 -07:00
Vito Caputo de770b6042 analyze: switch to BusLocator-oriented helpers
Mechanical substitution reducing some verbosity
2020-05-07 08:46:43 -07:00
Zbigniew Jędrzejewski-Szmek be32732168 basic/set: let set_put_strdup() create the set with string hash ops
If we're using a set with _put_strdup(), most of the time we want to use
string hash ops on the set, and free the strings when done. This defines
the appropriate a new string_hash_ops_free structure to automatically free
the keys when removing the set, and makes set_put_strdup() and set_put_strdupv()
instantiate the set with those hash ops.

hashmap_put_strdup() was already doing something similar.

(It is OK to instantiate the set earlier, possibly with a different hash ops
structure. set_put_strdup() will then use the existing set. It is also OK
to call set_free_free() instead of set_free() on a set with
string_hash_ops_free, the effect is the same, we're just overriding the
override of the cleanup function.)

No functional change intended.
2020-05-06 16:54:06 +02:00
Haochen Tong 47cc458e97 analyze: fix table time output 2020-03-09 14:58:25 +01:00
Alin Popa ad5555b42e systemd: Fix busctl crash on aarch64 when setting output table format
The enum used for column names is integer type while table_set_display() is parsing
arguments on size_t alignment which may result in assert in table_set_display() if
the size between types missmatch. This patch cast the enums to size_t.
It also fixes all other occurences for table_set_display() and
table_set_sort().
2020-02-16 02:09:26 +09:00
Yu Watanabe 222a6aace7
Merge pull request #14547 from keszybz/networkctl-matching
networkctl: return error or warning when interfaces are not matched
2020-01-15 11:56:01 +09:00
Zbigniew Jędrzejewski-Szmek 191a3f1634 basic/strv: drop flags argument from strv_fnmatch() 2020-01-14 13:10:29 +01:00
Yu Watanabe 9c46b437fc analyze: optimize table creation by using table_add_many() 2020-01-10 18:28:09 +09:00
Zbigniew Jędrzejewski-Szmek 26e1e97345 analyze: deprecate the commands moved to systemctl
This just removes the commands from --help and the man pages, everything works
as before.
2019-11-18 16:28:38 +01:00
Zbigniew Jędrzejewski-Szmek 6ab863190d systemctl: add service-watchdogs command
The rationale is the same as for log-level/log-target: this controls the behaviour
of the manager, and belongs in systemctl.
2019-11-18 16:28:38 +01:00
Zbigniew Jędrzejewski-Szmek 6962cf2e2a analyze: adjust the description of the default verb 2019-11-18 16:27:15 +01:00
Lennart Poettering 353b2baa20 tree-wide: clean up --help texts a bit
This cleans up and unifies the outut of --help texts a bit:

1. Highlight the human friendly description string, not the command
   line via ANSI sequences. Previously both this description string and
   the brief command line summary was marked with the same ANSI
   highlight sequence, but given we auto-page to less and less does not
   honour multi-line highlights only the command line summary was
   affectively highlighted. Rationale: for highlighting the description
   instead of the command line: the command line summary is relatively
   boring, and mostly the same for out tools, the description on the
   other hand is pregnant, important and captions the whole thing and
   hence deserves highlighting.

2. Always suffix "Options" with ":" in the help text

3. Rename "Flags" →  "Options" in one case

4. Move commands to the top in a few cases

5. add coloring to many more help pages

6. Unify on COMMAND instead of {COMMAND} in the command line summary.
   Some tools did it one way, others the other way. I am not sure what
   precisely {} is supposed to mean, that uppercasing doesn't, hence
   let's simplify and stick to the {}-less syntax

And minor other tweaks.
2019-11-18 15:14:43 +01:00
Lennart Poettering d816a5fcea analyze: drop spurious newline 2019-11-13 12:58:15 +01:00
Lennart Poettering 985c18802d analyze: add --base-time= to specify base time for 'calendar' verb 2019-11-13 12:57:17 +01:00
Yu Watanabe a969d60645 tree-wide: drop locale.h when locale-util.h is included 2019-11-04 00:30:32 +09:00
Lennart Poettering 81610e9609 analyze: fix minor memleak 2019-10-30 15:50:37 +01:00
Lennart Poettering ea334dc328 analyze: sort list of unknown syscalls kernel implements 2019-10-30 15:50:06 +01:00
Mike Gilbert 417b82e1c3 analyze: declare dump_exit_status outside of HAVE_SECCOMP block
Fixes: 76ed04d936
Closes: https://github.com/systemd/systemd/issues/13230
2019-07-31 09:43:03 +09:00
Lennart Poettering 5756bff6f1
Merge pull request #13119 from keszybz/unit-loading-2
Rework unit loading to take into account all aliases
2019-07-30 17:55:37 +02:00
Zbigniew Jędrzejewski-Szmek 91e0ee5f16 pid1: drop unit caches only based on mtime
v2:
- do not watch mtime of transient and generated dirs

  We'd reload the map after every transient unit we created, which we don't
  need to do, since we create those units ourselves and know their fragment
  path.
2019-07-30 14:01:46 +02:00
Zbigniew Jędrzejewski-Szmek e67cd21d7d analyze: add "unit-files" to dump the unit fragment map
I'm not convinced that this is useful enough to be included... But it is
certainly nice when debugging.
2019-07-30 14:01:46 +02:00
Lennart Poettering d68d0366dc analyze: clarify that 'exit-status' optionally takes arguments 2019-07-29 19:44:24 +02:00
Lennart Poettering d8e17e7356 analyze: right-align exit status column 2019-07-29 19:22:34 +02:00
Lennart Poettering 5238d9a83a analyze: rename "exit-codes" to "exit-status"
waitid(2) and the libc function signature calls this "exit status", and
uses "exit code" for something different. Let's stick to the same
nomenclature hence.
2019-07-29 19:22:22 +02:00
Lennart Poettering 563067ad26 analyze: always use "int" to display exit status values
That's what it actually is, hence let's use that and cast when the type
is bigger.
2019-07-29 19:14:09 +02:00
Lennart Poettering 1d7458fbb1
Merge pull request #13207 from keszybz/symbolic-exit-code-names
Symbolic exit code names
2019-07-29 18:58:06 +02:00
Lennart Poettering 49139a5d92 analyze: dot(1) man page link should be urlified
I mean, let's not miss out on this excellent opportunity to use
hyperlinks on terminals.

(Unfortunately not see unless you invoke 'systemd-analyze --no-pager
--help', because 'less' is so much stuck in the past :-(.)
2019-07-29 16:08:18 +02:00
Zbigniew Jędrzejewski-Szmek 76ed04d936 analyze: add exit-codes verb 2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek 4252171a94 tree-wide: use lowercase table headers
https://github.com/systemd/systemd/pull/13062#discussion_r303847484
> the formatter uppercases them anyway, and this way the JSON output of the
> formatter is nicer as it uses the table header fields 1:1 for the json
> output.
2019-07-16 14:29:04 +02:00
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