Commit graph

104 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 31a5924ed8 analyze: add unit-paths verb 2018-02-09 12:27:27 +01:00
Zbigniew Jędrzejewski-Szmek 28b35ef23a analyze: add --global option
This is somewhat useful for 'verify', and will be used later with 'unit-paths'.
2018-02-08 16:35:24 +01:00
Boucman d21b0c826f do not report total time when kernel time is not provided (#8063)
the whole systemd-analyze time logic is based on the fact that monotonic
time 0 is the start of the kernel.

If the firmware does not provide a correct time, firmware_time degrades to
0, which is the start of the kernel. The diference between FinishTime and
firmware_time is thus correct.

That assumption is still true with containers, but the start time of the
kernel is not what the user expects : It's the time when the host booted.

The total is thus still correct, but highly misleading. Containers can be
easily detected (and, in fact, already are) by systemd not reporting any
kernel non-monotonic timestamp.

This patch simply avoids printing a misleading time when it can detect that
case
2018-02-02 15:58:40 +01:00
Yu Watanabe 90657286fc analyze: merge {get,set}-log-{level,target} to log-{level,target} (#8020)
Also, service-watchdogs now shows current watchdog state when
no optional argument is provided.
2018-01-27 13:51:32 +01:00
Jan Klötzke 889d695d6c systemd-analyze: add service-watchdogs verb
New debug verb that enables or disables the service runtime watchdogs
and emergency actions during runtime. This is the systemd-analyze
version of the systemd.service_watchdogs command line option.
2018-01-22 18:10:12 +01:00
Boucman da933f7dcf fix systemd-analyze time when default.target is not reached (#7764)
Also, better error messages.
2018-01-03 15:52:13 +01:00
Lennart Poettering ad552e587f analyze: fix prototype mismatch on libseccomp-less builds (#7768)
This fixes a compiler warning that matters, if people build systemd
without libseccomp.

Follow-up for a6bcef2957
2018-01-01 13:24:41 +09:00
Lennart Poettering bc6695ec7e analyze: correct help text where we take unit name arguments 2017-12-26 16:04:10 +01:00
Lennart Poettering 8486c92394 analyze: fix indentation in one case 2017-12-26 16:04:10 +01:00
Lennart Poettering 8efbce138a analyze: add some logging to some error cases 2017-12-26 16:04:10 +01:00
Lennart Poettering f72b7018d2 analyze: arg_host can be "const char*", hence make it so. 2017-12-26 16:04:10 +01:00
Lennart Poettering a6bcef2957 analyze: port verb dispatching to verbs.[ch] API
Let's unify the code for parsing command line verbs, and reuse the
common verbs.[ch] API in systemd-analyze too.

This adds a couple of error messages when people pass too many
arguments. Moreover thus pushes bus allocation into the verb functions,
which corrects a couple of cases where we previously allocated a bus but
really didn't need to.

Other than that behaviour shouldn't really change.
2017-12-26 16:04:10 +01:00
Zbigniew Jędrzejewski-Szmek bf0e0a4df2 analyze: use normal bus connection for "plot" verb (#7685)
We need to connect to hostnamed, so a private bus connection is no good.
It'd be simpler to use the normal bus connection unconditionally, but
that'd mean that e.g. systemd-analyze set-log-level might not work in
emergency mode. So let's keep trying to use the private connection except
for "plot".

Fixes #7667.
2017-12-18 19:35:03 +01:00
Lennart Poettering 234519ae6d tree-wide: drop a few == NULL and != NULL comparison
Our CODING_STYLE suggests not comparing with NULL, but relying on C's
downgrade-to-bool feature for that. Fix up some code to match these
guidelines. (This is not comprehensive, the coccinelle output for this
is unfortunately kinda borked)
2017-12-11 16:05:40 +01:00
Boucman bd07d3d0b4 Print the time to reach default.target in systemd-analyze time (#7383)
Example output (last line is new):
$ systemd-analyze time
Startup finished in 12.879s (firmware) + 36.999s (loader) + 1.313s (kernel) + 22.672s (initrd) + 3min 1.755s (userspace) = 4min 15.619s
graphical.target reached after 1min 39.377s in userspace
2017-12-05 10:20:40 +01:00
Lennart Poettering 6d86f4bd11 analyze: add new "calendar" command
This little new command can parse, validate, normalize calendar events,
and calculate when they will elapse next. This should be useful for
anyone writing calendar events and who'd like to validate the expression
before running them as timer units.
2017-11-20 10:57:41 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek 349cc4a507 build-sys: use #if Y instead of #ifdef Y everywhere
The advantage is that is the name is mispellt, cpp will warn us.

$ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/"
$ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;'
$ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g'
$ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g'
+ manual changes to meson.build

squash! build-sys: use #if Y instead of #ifdef Y everywhere

v2:
- fix incorrect setting of HAVE_LIBIDN2
2017-10-04 12:09:29 +02:00
Zbigniew Jędrzejewski-Szmek 641c0fd14e analyze-verify: add --generators switch to enable generators again 2017-09-19 20:14:22 +02:00
Lucas Werkmeister ef5a8cb1a7 analyze: add get-log-level, get-log-target verbs
They’re counterparts to the existing set-log-level and set-log-target
verbs, simply printing the current value to stdout. This makes it
slightly easier to temporarily change the log level and/or target and
then restore the old value(s).
2017-09-07 23:55:59 +02:00
Zbigniew Jędrzejewski-Szmek 948aaa7c52 tree-wide: standardize on $(PACKAGE_VERSION) for the version string
We defined both $(VERSION) and $(PACKAGE_VERSION) with the same contents.
$(PACKAGE_VERSION) is slightly more descriptive, so settle on that, and
drop the other define.
2017-04-04 20:36:09 -04:00
Lucas Werkmeister cc7de2ba32 tree-wide: add man: to manpage references (#5402)
Found with:

    git grep '"[^"]*[a-z0-9]([0-9]\+p\?)' src/ | grep -vF man:
2017-02-20 18:45:35 -05:00
Lennart Poettering f9e0eefc7c tree-wide: make bus_map_all_properties return a proper sd_bus_error
And then show it, to make things a bit friendlier to the user if we fail
acquiring some props.

In fact, this fixes a number of actual bugs, where we used an error
structure for output that we actually never got an error in.
2017-02-09 16:13:07 +01:00
Franck Bui 0f734bdca5 analyze: fix build without seccomp 2016-11-10 10:12:31 +01:00
Zbigniew Jędrzejewski-Szmek 1720590bfd analyze: fix build w/o seccomp 2016-11-03 16:23:12 -04:00
Zbigniew Jędrzejewski-Szmek d5efc18b60 seccomp-util, analyze: export comments as a help string
Just to make the whole thing easier for users.
2016-11-03 09:35:36 -04:00
Zbigniew Jędrzejewski-Szmek 869feb3388 analyze: add syscall-filter verb
This should make it easier for users to understand what each filter
means as the list of syscalls is updated in subsequent systemd versions.
2016-11-03 09:35:35 -04:00
Lennart Poettering 54f8c958f1 tree-wide: use ansi_highlight() instead of ANSI_HIGHLIGHT where appropriate
Let's make sure SYSTEMD_COLORS is honour by more tools
2016-05-30 18:22:16 +02:00
Zbigniew Jędrzejewski-Szmek 323b7dc903 tree-wide: rename draw_special_char to special_glyph
That function doesn't draw anything on it's own, just returns a string, which
sometimes is more than one character. Also remove "DRAW_" prefix from character
names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't
draw anything, and are always used as an argument to special_glyph().

Rename "DASH" to "MDASH", as there's more than one type of dash.
2016-05-09 15:17:57 -04:00
Lennart Poettering 20b1644140 shared: move unit-specific code from bus-util.h to bus-unit-util.h
Previously we'd have generally useful sd-bus utilities in bust-util.h,
intermixed with code that is specifically for writing clients for PID 1,
wrapping job and unit handling. Let's split the latter out and move it into
bus-unit-util.c, to make the sources a bit short and easier to grok.
2016-04-22 16:06:20 +02:00
Lennart Poettering 463d0d1569 core: remove ManagerRunningAs enum
Previously, we had two enums ManagerRunningAs and UnitFileScope, that were
mostly identical and converted from one to the other all the time. The latter
had one more value UNIT_FILE_GLOBAL however.

Let's simplify things, and remove ManagerRunningAs and replace it by
UnitFileScope everywhere, thus making the translation unnecessary. Introduce
two new macros MANAGER_IS_SYSTEM() and MANAGER_IS_USER() to simplify checking
if we are running in one or the user context.
2016-04-12 13:43:30 +02:00
Zbigniew Jędrzejewski-Szmek 06fb28b16e Merge pull request #2671 from 0xAX/move-pager-open-to-one-place
tree-wide: merge pager_open_if_enabled() to the pager_open()
2016-02-25 15:29:59 -05:00
Alexander Kuleshov ea4b98e657 tree-wide: merge pager_open_if_enabled() to the pager_open()
Many subsystems define own pager_open_if_enabled() function which
checks '--no-pager' command line argument and open pager depends
on its value. All implementations of pager_open_if_enabled() are
the same. Let's merger this function with pager_open() from the
shared/pager.c and remove pager_open_if_enabled() from all subsytems
to prevent code duplication.
2016-02-26 01:13:23 +06:00
Vito Caputo 9ed794a32d tree-wide: minor formatting inconsistency cleanups 2016-02-23 14:20:34 -08:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering 4afd3348c7 tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.

With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.

The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).

This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.

Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:

       #define _cleanup_(function) __attribute__((cleanup(function)))

Or similar, to make the gcc feature easier to use.

Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.

See #2008.
2015-11-27 19:19:36 +01:00
Michal Schmidt fa4b687b63 analyze: do not draw ConflictedBy dependencies in dot graph
We already draw Conflicts. I see no reason for having every red line in
the graph duplicated in the opposite direction.
2015-11-13 15:01:56 +01:00
Michal Schmidt 8901b40502 analyze: show Requisite dependencies in the dot graph again
We lost them a long time ago with commit 048ecf5b84.
2015-11-13 14:32:59 +01:00
Lennart Poettering f32b43bda4 core: remove support for RequiresOverridable= and RequisiteOverridable=
As discussed at systemd.conf 2015 and on also raised on the ML:

http://lists.freedesktop.org/archives/systemd-devel/2015-November/034880.html

This removes the two XyzOverridable= unit dependencies, that were
basically never used, and do not enhance user experience in any way.
Most folks looking for the functionality this provides probably opt for
the "ignore-dependencies" job mode, and that's probably a good idea.

Hence, let's simplify systemd's dependency engine and remove these two
dependency types (and their inverses).

The unit file parser and the dbus property parser will now redirect
the settings/properties to result in an equivalent non-overridable
dependency. In the case of the unit file parser we generate a warning,
to inform the user.

The dbus properties for this unit type stay available on the unit
objects, but they are now hidden from usual introspection and will
always return the empty list when queried.

This should provide enough compatibility for the few unit files that
actually ever made use of this.
2015-11-12 19:27:24 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 7d50b32a12 util-lib: split out globbing related calls into glob-util.[ch] 2015-10-27 13:25:58 +01:00
Lennart Poettering 8752c5752f util-lib: move more locale-related calls to locale-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering 6bedfcbb29 util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering b1b533a060 analyze: trivial code cleanups 2015-10-07 15:45:39 +02:00
Łukasz Stelmach febda62a36 analyze: minor fixes according to review
+ use _cleanup_host_info in acquire_host_info()

+ revert the first strempty() to show "Linux" string in case
  os_pretty_name is missing.
2015-10-07 08:02:31 +02:00
Łukasz Stelmach caeacefe9f analyze: replace isempty()+ternary with strempty() 2015-10-06 17:56:19 +02:00
Łukasz Stelmach 6cdf0399f3 analyze: do not require information from hostnamed 2015-10-06 17:56:19 +02:00
Łukasz Stelmach 19f462f2de analyze: introduce _cleanup_host_info_ 2015-10-06 17:56:12 +02:00
Lennart Poettering 2ca2a91cf1 analyze: add new set-log-target subcommand
We already have the property writable, hence let's add a command to set
it.
2015-09-30 15:25:23 +02:00
Lennart Poettering 266f3e269d bus-util: rename bus_open_transport() to bus_connect_transport()
In sd-bus, the sd_bus_open_xyz() family of calls allocates a new bus,
while sd_bus_default_xyz() family tries to reuse the thread's default
bus. bus_open_transport() sometimes internally uses the former,
sometimes the latter family, but suggests it only calls the former via
its name. Hence, let's avoid this confusion, and generically rename the
call to bus_connect_transport().

Similar for all related calls.

And while we are at it, also change cgls + cgtop to do direct systemd
connections where possible, since all they do is talk to systemd itself.
2015-09-29 21:55:52 +02:00