From 38fcb7f766c84736425e86854b8a4468c126dafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 15 Nov 2019 09:39:50 +0100 Subject: [PATCH 1/5] systemctl: add log-level and log-target commands This copies the commands log-level and log-target (to query and set the current settings) from systemd-analyze to systemctl, essentially reverting a65615ca5d78be0dcd7d9c9b4a663fa75f758606. Controllling the log level settings of the manager is basic functionality, that should be available even if systemd-analyze (which is more of an analysis tool) is not installed. This is like dmesg and journalctl, which should be available even if a debugger and more advanced tools to analyze the kernel are not available. (Note that dmesg is used to control the log level too, not just to browse the kernel logs.) I chose to copy&paste the methods from analyze.c to the new location. There isn't enough code to share, because acquire_bus() in both places has a different signature despite the same name, so the only part that is common is the invocation of sd_bus_set_property(). --- man/systemctl.xml | 25 ++++- src/systemctl/systemctl.c | 228 ++++++++++++++++++++++++++------------ 2 files changed, 184 insertions(+), 69 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index 0e3b90b266..0c0eee5552 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -1032,7 +1032,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err - Manager Lifecycle Commands + Manager State Commands @@ -1051,6 +1051,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err reload command. + daemon-reexec @@ -1065,6 +1066,28 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err + + + log-level [LEVEL] + + If no argument is given, print the current log level of the manager. If an + optional argument LEVEL is provided, then the command changes the + current log level of the manager to LEVEL (accepts the same values as + described in + systemd1). + + + + + log-target [TARGET] + + If no argument is given, print the current log target of the manager. If an + optional argument TARGET is provided, then the command changes the + current log target of the manager to TARGET (accepts the same values as + , described in + systemd1). + + diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 9200810654..96de89e307 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6343,6 +6343,94 @@ static int switch_root(int argc, char *argv[], void *userdata) { return 0; } +static int log_level(int argc, char *argv[], void *userdata) { + sd_bus *bus; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int r; + + r = acquire_bus(BUS_MANAGER, &bus); + if (r < 0) + return r; + + if (argc == 1) { + _cleanup_free_ char *level = NULL; + + r = sd_bus_get_property_string( + bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "LogLevel", + &error, + &level); + if (r < 0) + return log_error_errno(r, "Failed to get log level: %s", bus_error_message(&error, r)); + + puts(level); + + } else { + assert(argc == 2); + + r = sd_bus_set_property( + bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "LogLevel", + &error, + "s", + argv[1]); + if (r < 0) + return log_error_errno(r, "Failed to set log level: %s", bus_error_message(&error, r)); + } + + return 0; +} + +static int log_target(int argc, char *argv[], void *userdata) { + sd_bus *bus; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int r; + + r = acquire_bus(BUS_MANAGER, &bus); + if (r < 0) + return r; + + if (argc == 1) { + _cleanup_free_ char *target = NULL; + + r = sd_bus_get_property_string( + bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "LogTarget", + &error, + &target); + if (r < 0) + return log_error_errno(r, "Failed to get log target: %s", bus_error_message(&error, r)); + + puts(target); + + } else { + assert(argc == 2); + + r = sd_bus_set_property( + bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "LogTarget", + &error, + "s", + argv[1]); + if (r < 0) + return log_error_errno(r, "Failed to set log target: %s", bus_error_message(&error, r)); + } + + return 0; +} + static int set_environment(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; @@ -7761,9 +7849,11 @@ static int systemctl_help(void) { " set-environment VARIABLE=VALUE... Set one or more environment variables\n" " unset-environment VARIABLE... Unset one or more environment variables\n" " import-environment [VARIABLE...] Import all or some environment variables\n\n" - "\n%3$sManager Lifecycle Commands:%4$s\n" + "\n%3$sManager State Commands:%4$s\n" " daemon-reload Reload systemd manager configuration\n" " daemon-reexec Reexecute systemd manager\n" + " log-level [LEVEL] Get/set logging threshold for manager\n" + " log-target [TARGET] Get/set logging target for manager\n" "\n%3$sSystem Commands:%4$s\n" " is-system-running Check whether system is fully running\n" " default Enter system default mode\n" @@ -8955,73 +9045,75 @@ _pure_ static int action_to_runlevel(void) { static int systemctl_main(int argc, char *argv[]) { static const Verb verbs[] = { { "list-units", VERB_ANY, VERB_ANY, VERB_DEFAULT|VERB_ONLINE_ONLY, list_units }, - { "list-unit-files", VERB_ANY, VERB_ANY, 0, list_unit_files }, - { "list-sockets", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_sockets }, - { "list-timers", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_timers }, - { "list-jobs", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_jobs }, - { "list-machines", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_machines }, - { "clear-jobs", VERB_ANY, 1, VERB_ONLINE_ONLY, trivial_method }, - { "cancel", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, cancel_job }, - { "start", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, - { "stop", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, - { "condstop", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with ALTLinux */ - { "reload", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, - { "restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, - { "try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, - { "reload-or-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, - { "reload-or-try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with old systemctl <= 228 */ - { "try-reload-or-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, - { "force-reload", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with SysV */ - { "condreload", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with ALTLinux */ - { "condrestart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with RH */ - { "isolate", 2, 2, VERB_ONLINE_ONLY, start_unit }, - { "kill", 2, VERB_ANY, VERB_ONLINE_ONLY, kill_unit }, - { "clean", 2, VERB_ANY, VERB_ONLINE_ONLY, clean_unit }, - { "is-active", 2, VERB_ANY, VERB_ONLINE_ONLY, check_unit_active }, - { "check", 2, VERB_ANY, VERB_ONLINE_ONLY, check_unit_active }, /* deprecated alias of is-active */ - { "is-failed", 2, VERB_ANY, VERB_ONLINE_ONLY, check_unit_failed }, - { "show", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, show }, - { "cat", 2, VERB_ANY, VERB_ONLINE_ONLY, cat }, - { "status", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, show }, - { "help", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, show }, - { "daemon-reload", VERB_ANY, 1, VERB_ONLINE_ONLY, daemon_reload }, - { "daemon-reexec", VERB_ANY, 1, VERB_ONLINE_ONLY, daemon_reload }, - { "show-environment", VERB_ANY, 1, VERB_ONLINE_ONLY, show_environment }, - { "set-environment", 2, VERB_ANY, VERB_ONLINE_ONLY, set_environment }, - { "unset-environment", 2, VERB_ANY, VERB_ONLINE_ONLY, set_environment }, - { "import-environment", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, import_environment }, - { "halt", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "poweroff", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "reboot", VERB_ANY, 2, VERB_ONLINE_ONLY, start_system_special }, - { "kexec", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "suspend", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "hibernate", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "hybrid-sleep", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "suspend-then-hibernate",VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "default", VERB_ANY, 1, VERB_ONLINE_ONLY, start_special }, - { "rescue", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "emergency", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, - { "exit", VERB_ANY, 2, VERB_ONLINE_ONLY, start_special }, - { "reset-failed", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, reset_failed }, - { "enable", 2, VERB_ANY, 0, enable_unit }, - { "disable", 2, VERB_ANY, 0, enable_unit }, - { "is-enabled", 2, VERB_ANY, 0, unit_is_enabled }, - { "reenable", 2, VERB_ANY, 0, enable_unit }, - { "preset", 2, VERB_ANY, 0, enable_unit }, - { "preset-all", VERB_ANY, 1, 0, preset_all }, - { "mask", 2, VERB_ANY, 0, enable_unit }, - { "unmask", 2, VERB_ANY, 0, enable_unit }, - { "link", 2, VERB_ANY, 0, enable_unit }, - { "revert", 2, VERB_ANY, 0, enable_unit }, - { "switch-root", 2, VERB_ANY, VERB_ONLINE_ONLY, switch_root }, - { "list-dependencies", VERB_ANY, 2, VERB_ONLINE_ONLY, list_dependencies }, - { "set-default", 2, 2, 0, set_default }, - { "get-default", VERB_ANY, 1, 0, get_default }, - { "set-property", 3, VERB_ANY, VERB_ONLINE_ONLY, set_property }, - { "is-system-running", VERB_ANY, 1, 0, is_system_running }, - { "add-wants", 3, VERB_ANY, 0, add_dependency }, - { "add-requires", 3, VERB_ANY, 0, add_dependency }, - { "edit", 2, VERB_ANY, VERB_ONLINE_ONLY, edit }, + { "list-unit-files", VERB_ANY, VERB_ANY, 0, list_unit_files }, + { "list-sockets", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_sockets }, + { "list-timers", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_timers }, + { "list-jobs", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_jobs }, + { "list-machines", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_machines }, + { "clear-jobs", VERB_ANY, 1, VERB_ONLINE_ONLY, trivial_method }, + { "cancel", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, cancel_job }, + { "start", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, + { "stop", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, + { "condstop", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with ALTLinux */ + { "reload", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, + { "restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, + { "try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, + { "reload-or-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, + { "reload-or-try-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with old systemctl <= 228 */ + { "try-reload-or-restart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, + { "force-reload", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with SysV */ + { "condreload", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with ALTLinux */ + { "condrestart", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit }, /* For compatibility with RH */ + { "isolate", 2, 2, VERB_ONLINE_ONLY, start_unit }, + { "kill", 2, VERB_ANY, VERB_ONLINE_ONLY, kill_unit }, + { "clean", 2, VERB_ANY, VERB_ONLINE_ONLY, clean_unit }, + { "is-active", 2, VERB_ANY, VERB_ONLINE_ONLY, check_unit_active }, + { "check", 2, VERB_ANY, VERB_ONLINE_ONLY, check_unit_active }, /* deprecated alias of is-active */ + { "is-failed", 2, VERB_ANY, VERB_ONLINE_ONLY, check_unit_failed }, + { "show", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, show }, + { "cat", 2, VERB_ANY, VERB_ONLINE_ONLY, cat }, + { "status", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, show }, + { "help", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, show }, + { "daemon-reload", VERB_ANY, 1, VERB_ONLINE_ONLY, daemon_reload }, + { "daemon-reexec", VERB_ANY, 1, VERB_ONLINE_ONLY, daemon_reload }, + { "log-level", VERB_ANY, 2, 0, log_level }, + { "log-target", VERB_ANY, 2, 0, log_target }, + { "show-environment", VERB_ANY, 1, VERB_ONLINE_ONLY, show_environment }, + { "set-environment", 2, VERB_ANY, VERB_ONLINE_ONLY, set_environment }, + { "unset-environment", 2, VERB_ANY, VERB_ONLINE_ONLY, set_environment }, + { "import-environment", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, import_environment }, + { "halt", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "poweroff", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "reboot", VERB_ANY, 2, VERB_ONLINE_ONLY, start_system_special }, + { "kexec", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "suspend", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "hibernate", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "hybrid-sleep", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "suspend-then-hibernate",VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "default", VERB_ANY, 1, VERB_ONLINE_ONLY, start_special }, + { "rescue", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "emergency", VERB_ANY, 1, VERB_ONLINE_ONLY, start_system_special }, + { "exit", VERB_ANY, 2, VERB_ONLINE_ONLY, start_special }, + { "reset-failed", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, reset_failed }, + { "enable", 2, VERB_ANY, 0, enable_unit }, + { "disable", 2, VERB_ANY, 0, enable_unit }, + { "is-enabled", 2, VERB_ANY, 0, unit_is_enabled }, + { "reenable", 2, VERB_ANY, 0, enable_unit }, + { "preset", 2, VERB_ANY, 0, enable_unit }, + { "preset-all", VERB_ANY, 1, 0, preset_all }, + { "mask", 2, VERB_ANY, 0, enable_unit }, + { "unmask", 2, VERB_ANY, 0, enable_unit }, + { "link", 2, VERB_ANY, 0, enable_unit }, + { "revert", 2, VERB_ANY, 0, enable_unit }, + { "switch-root", 2, VERB_ANY, VERB_ONLINE_ONLY, switch_root }, + { "list-dependencies", VERB_ANY, 2, VERB_ONLINE_ONLY, list_dependencies }, + { "set-default", 2, 2, 0, set_default }, + { "get-default", VERB_ANY, 1, 0, get_default }, + { "set-property", 3, VERB_ANY, VERB_ONLINE_ONLY, set_property }, + { "is-system-running", VERB_ANY, 1, 0, is_system_running }, + { "add-wants", 3, VERB_ANY, 0, add_dependency }, + { "add-requires", 3, VERB_ANY, 0, add_dependency }, + { "edit", 2, VERB_ANY, VERB_ONLINE_ONLY, edit }, {} }; From 6962cf2e2ab6ec28aff0b31d1db701a679ab6efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 15 Nov 2019 09:55:43 +0100 Subject: [PATCH 2/5] analyze: adjust the description of the default verb --- src/analyze/analyze.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index c7f74274cb..e725878b03 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -2246,7 +2246,7 @@ static int help(int argc, char *argv[], void *userdata) { printf("%s [OPTIONS...] COMMAND ...\n\n" "%sProfile systemd, show unit dependencies, check unit files.%s\n" "\nCommands:\n" - " time Print time spent in the kernel\n" + " [time] Print time required to boot the machine\n" " blame Print list of running units ordered by time to init\n" " critical-chain [UNIT...] Print a tree of the time critical chain of units\n" " plot Output SVG graphic showing service initialization\n" From 6ab863190dee5ab631795ef547fcc7314ddccd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 15 Nov 2019 10:14:57 +0100 Subject: [PATCH 3/5] 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. --- man/systemctl.xml | 11 ++++++++ src/analyze/analyze.c | 37 +++++++++++++-------------- src/systemctl/systemctl.c | 53 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 20 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index 0c0eee5552..fb0ca46620 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -1088,6 +1088,17 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err systemd1). + + + service-watchdogs [yes|no] + + If no argument is given, print the current state of service runtime watchdogs of + the manager. If an optional boolean argument is provided, then globally enables or disables the + service runtime watchdogs () and emergency actions (e.g. + or ); see + systemd.service5. + The hardware watchdog is not affected by this setting. + diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index e725878b03..b242f70b37 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -2166,8 +2166,8 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to create bus connection: %m"); - /* get ServiceWatchdogs */ if (argc == 1) { + /* get ServiceWatchdogs */ r = sd_bus_get_property_trivial( bus, "org.freedesktop.systemd1", @@ -2182,28 +2182,25 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) { printf("%s\n", yes_no(!!b)); - return 0; - } + } else { + /* set ServiceWatchdogs */ + b = parse_boolean(argv[1]); + if (b < 0) + return log_error_errno(b, "Failed to parse service-watchdogs argument: %m"); - /* set ServiceWatchdogs */ - b = parse_boolean(argv[1]); - if (b < 0) { - log_error("Failed to parse service-watchdogs argument."); - return -EINVAL; + r = sd_bus_set_property( + bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "ServiceWatchdogs", + &error, + "b", + b); + if (r < 0) + return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r)); } - r = sd_bus_set_property( - bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", - "org.freedesktop.systemd1.Manager", - "ServiceWatchdogs", - &error, - "b", - b); - if (r < 0) - return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r)); - return 0; } diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 96de89e307..a771c75f5f 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6431,6 +6431,57 @@ static int log_target(int argc, char *argv[], void *userdata) { return 0; } +static int service_watchdogs(int argc, char *argv[], void *userdata) { + sd_bus *bus; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int b, r; + + assert(argv); + + r = acquire_bus(BUS_MANAGER, &bus); + if (r < 0) + return r; + + if (argc == 1) { + /* get ServiceWatchdogs */ + r = sd_bus_get_property_trivial( + bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "ServiceWatchdogs", + &error, + 'b', + &b); + if (r < 0) + return log_error_errno(r, "Failed to get service-watchdog state: %s", bus_error_message(&error, r)); + + printf("%s\n", yes_no(!!b)); + + } else { + /* set ServiceWatchdogs */ + assert(argc == 2); + + b = parse_boolean(argv[1]); + if (b < 0) + return log_error_errno(b, "Failed to parse service-watchdogs argument: %m"); + + r = sd_bus_set_property( + bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "ServiceWatchdogs", + &error, + "b", + b); + if (r < 0) + return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r)); + } + + return 0; +} + static int set_environment(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; @@ -7854,6 +7905,7 @@ static int systemctl_help(void) { " daemon-reexec Reexecute systemd manager\n" " log-level [LEVEL] Get/set logging threshold for manager\n" " log-target [TARGET] Get/set logging target for manager\n" + " service-watchdogs [BOOL] Get/set service watchdog state\n" "\n%3$sSystem Commands:%4$s\n" " is-system-running Check whether system is fully running\n" " default Enter system default mode\n" @@ -9078,6 +9130,7 @@ static int systemctl_main(int argc, char *argv[]) { { "daemon-reexec", VERB_ANY, 1, VERB_ONLINE_ONLY, daemon_reload }, { "log-level", VERB_ANY, 2, 0, log_level }, { "log-target", VERB_ANY, 2, 0, log_target }, + { "service-watchdogs", VERB_ANY, 2, 0, service_watchdogs }, { "show-environment", VERB_ANY, 1, VERB_ONLINE_ONLY, show_environment }, { "set-environment", 2, VERB_ANY, VERB_ONLINE_ONLY, set_environment }, { "unset-environment", 2, VERB_ANY, VERB_ONLINE_ONLY, set_environment }, From 26e1e9734524d5fc53b2ca876d5d5478b3ef3c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 15 Nov 2019 09:57:24 +0100 Subject: [PATCH 4/5] analyze: deprecate the commands moved to systemctl This just removes the commands from --help and the man pages, everything works as before. --- man/systemd-analyze.xml | 50 ----------------------------------------- src/analyze/analyze.c | 7 ++---- 2 files changed, 2 insertions(+), 55 deletions(-) diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml index 02d7179e4c..dcb7cf29c1 100644 --- a/man/systemd-analyze.xml +++ b/man/systemd-analyze.xml @@ -39,25 +39,6 @@ UNIT - - systemd-analyze - OPTIONS - log-level - LEVEL - - - systemd-analyze - OPTIONS - log-target - TARGET - - - systemd-analyze - OPTIONS - service-watchdogs - BOOL - - systemd-analyze OPTIONS @@ -241,37 +222,6 @@ multi-user.target @47.820s - - <command>systemd-analyze log-level [<replaceable>LEVEL</replaceable>]</command> - - systemd-analyze log-level prints the current log level of the - systemd daemon. If an optional argument LEVEL is - provided, then the command changes the current log level of the systemd daemon to - LEVEL (accepts the same values as described in - systemd1). - - - - <command>systemd-analyze log-target [<replaceable>TARGET</replaceable>]</command> - - systemd-analyze log-target prints the current log target of the - systemd daemon. If an optional argument TARGET is - provided, then the command changes the current log target of the systemd daemon to - TARGET (accepts the same values as , described - in systemd1). - - - - <command>systemd-analyze service-watchdogs [yes|no]</command> - - systemd-analyze service-watchdogs prints the current state of service runtime - watchdogs of the systemd daemon. If an optional boolean argument is provided, then - globally enables or disables the service runtime watchdogs () and - emergency actions (e.g. or ); see - systemd.service5. - The hardware watchdog is not affected by this setting. - - <command>systemd-analyze dump</command> diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index b242f70b37..991e61de7e 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -2248,8 +2248,6 @@ static int help(int argc, char *argv[], void *userdata) { " critical-chain [UNIT...] Print a tree of the time critical chain of units\n" " plot Output SVG graphic showing service initialization\n" " dot [UNIT...] Output dependency graph in %s format\n" - " log-level [LEVEL] Get/set logging threshold for manager\n" - " log-target [TARGET] Get/set logging target for manager\n" " dump Output state serialization of service manager\n" " cat-config Show configuration file and drop-ins\n" " unit-files List files and symlinks for units\n" @@ -2258,7 +2256,6 @@ static int help(int argc, char *argv[], void *userdata) { " syscall-filter [NAME...] Print list of syscalls in seccomp filter\n" " condition CONDITION... Evaluate conditions and asserts\n" " verify FILE... Check unit files for correctness\n" - " service-watchdogs [BOOL] Get/set service watchdog state\n" " calendar SPEC... Validate repetitive calendar time events\n" " timestamp TIMESTAMP... Validate a timestamp\n" " timespan SPAN... Validate a time span\n" @@ -2479,13 +2476,14 @@ static int run(int argc, char *argv[]) { { "critical-chain", VERB_ANY, VERB_ANY, 0, analyze_critical_chain }, { "plot", VERB_ANY, 1, 0, analyze_plot }, { "dot", VERB_ANY, VERB_ANY, 0, dot }, + /* The following seven verbs are deprecated */ { "log-level", VERB_ANY, 2, 0, get_or_set_log_level }, { "log-target", VERB_ANY, 2, 0, get_or_set_log_target }, - /* The following four verbs are deprecated aliases */ { "set-log-level", 2, 2, 0, set_log_level }, { "get-log-level", VERB_ANY, 1, 0, get_log_level }, { "set-log-target", 2, 2, 0, set_log_target }, { "get-log-target", VERB_ANY, 1, 0, get_log_target }, + { "service-watchdogs", VERB_ANY, 2, 0, service_watchdogs }, { "dump", VERB_ANY, 1, 0, dump }, { "cat-config", 2, VERB_ANY, 0, cat_config }, { "unit-files", VERB_ANY, VERB_ANY, 0, do_unit_files }, @@ -2497,7 +2495,6 @@ static int run(int argc, char *argv[]) { { "calendar", 2, VERB_ANY, 0, test_calendar }, { "timestamp", 2, VERB_ANY, 0, test_timestamp }, { "timespan", 2, VERB_ANY, 0, dump_timespan }, - { "service-watchdogs", VERB_ANY, 2, 0, service_watchdogs }, { "security", VERB_ANY, VERB_ANY, 0, do_security }, {} }; From 4d985a317a5a58ad1938a39f2a04f0b3a998f52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 18 Nov 2019 16:41:13 +0100 Subject: [PATCH 5/5] systemctl: whitespace optimization of --help Move the explanation of options three columns to the right: then almost all options fit and we do not need to break lines so often. When a multi-line explanation precedes a section break, i.e. there is a half-line on the right side, do not use an empty space. This saves a line, and actually looks visually better because the text is still clearly separated, but we don't get the big vertical white space. --- src/systemctl/systemctl.c | 113 ++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 59 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index a771c75f5f..07357c6edc 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -7866,7 +7866,7 @@ static int systemctl_help(void) { " units\n" " list-dependencies [UNIT] Recursively show units which are required\n" " or wanted by this unit or by which this\n" - " unit is required or wanted\n" + " unit is required or wanted" "\n%3$sUnit File Commands:%4$s\n" " list-unit-files [PATTERN...] List installed unit files\n" " enable [UNIT...|PATH...] Enable one or more unit files\n" @@ -7891,7 +7891,7 @@ static int systemctl_help(void) { " get-default Get the name of the default target\n" " set-default TARGET Set the default target\n" "\n%3$sMachine Commands:%4$s\n" - " list-machines [PATTERN...] List local containers and host\n\n" + " list-machines [PATTERN...] List local containers and host\n" "\n%3$sJob Commands:%4$s\n" " list-jobs [PATTERN...] List jobs\n" " cancel [JOB...] Cancel all, one, or more jobs\n" @@ -7899,7 +7899,7 @@ static int systemctl_help(void) { " show-environment Dump environment\n" " set-environment VARIABLE=VALUE... Set one or more environment variables\n" " unset-environment VARIABLE... Unset one or more environment variables\n" - " import-environment [VARIABLE...] Import all or some environment variables\n\n" + " import-environment [VARIABLE...] Import all or some environment variables\n" "\n%3$sManager State Commands:%4$s\n" " daemon-reload Reload systemd manager configuration\n" " daemon-reexec Reexecute systemd manager\n" @@ -7921,68 +7921,63 @@ static int systemctl_help(void) { " hibernate Hibernate the system\n" " hybrid-sleep Hibernate and suspend the system\n" " suspend-then-hibernate Suspend the system, wake after a period of\n" - " time and put it into hibernate\n" + " time, and hibernate" "\n%3$sOptions:%4$s\n" - " -h --help Show this help\n" - " --version Show package version\n" - " --system Connect to system manager\n" - " --user Connect to user service manager\n" - " -H --host=[USER@]HOST\n" - " Operate on remote host\n" - " -M --machine=CONTAINER\n" - " Operate on local container\n" - " -t --type=TYPE List units of a particular type\n" - " --state=STATE List units with particular LOAD or SUB or ACTIVE state\n" - " --failed Shorcut for --state=failed\n" - " -p --property=NAME Show only properties by this name\n" - " -a --all Show all properties/all units currently in memory,\n" - " including dead/empty ones. To list all units installed on\n" - " the system, use the 'list-unit-files' command instead.\n" - " -l --full Don't ellipsize unit names on output\n" - " -r --recursive Show unit list of host and local containers\n" - " --reverse Show reverse dependencies with 'list-dependencies'\n" - " --job-mode=MODE Specify how to deal with already queued jobs, when\n" - " queueing a new job\n" - " -T --show-transaction\n" - " When enqueuing a unit job, show full transaction\n" - " --show-types When showing sockets, explicitly show their type\n" - " --value When showing properties, only print the value\n" - " -i --ignore-inhibitors\n" - " When shutting down or sleeping, ignore inhibitors\n" - " --kill-who=WHO Who to send signal to\n" - " -s --signal=SIGNAL Which signal to send\n" - " --what=RESOURCES Which types of resources to remove\n" - " --now Start or stop unit in addition to enabling or disabling it\n" - " --dry-run Only print what would be done\n" - " -q --quiet Suppress output\n" - " --wait For (re)start, wait until service stopped again\n" - " For is-system-running, wait until startup is completed\n" - " --no-block Do not wait until operation finished\n" - " --no-wall Don't send wall message before halt/power-off/reboot\n" - " --no-reload Don't reload daemon after en-/dis-abling unit files\n" - " --no-legend Do not print a legend (column headers and hints)\n" - " --no-pager Do not pipe output into a pager\n" - " --no-ask-password\n" - " Do not ask for system passwords\n" - " --global Enable/disable/mask unit files globally\n" - " --runtime Enable/disable/mask unit files temporarily until next\n" - " reboot\n" - " -f --force When enabling unit files, override existing symlinks\n" - " When shutting down, execute action immediately\n" - " --preset-mode= Apply only enable, only disable, or all presets\n" - " --root=PATH Enable/disable/mask unit files in the specified root\n" - " directory\n" - " -n --lines=INTEGER Number of journal entries to show\n" - " -o --output=STRING Change journal output mode (short, short-precise,\n" + " -h --help Show this help\n" + " --version Show package version\n" + " --system Connect to system manager\n" + " --user Connect to user service manager\n" + " -H --host=[USER@]HOST Operate on remote host\n" + " -M --machine=CONTAINER Operate on a local container\n" + " -t --type=TYPE List units of a particular type\n" + " --state=STATE List units with particular LOAD or SUB or ACTIVE state\n" + " --failed Shorcut for --state=failed\n" + " -p --property=NAME Show only properties by this name\n" + " -a --all Show all properties/all units currently in memory,\n" + " including dead/empty ones. To list all units installed\n" + " on the system, use 'list-unit-files' instead.\n" + " -l --full Don't ellipsize unit names on output\n" + " -r --recursive Show unit list of host and local containers\n" + " --reverse Show reverse dependencies with 'list-dependencies'\n" + " --job-mode=MODE Specify how to deal with already queued jobs, when\n" + " queueing a new job\n" + " -T --show-transaction When enqueuing a unit job, show full transaction\n" + " --show-types When showing sockets, explicitly show their type\n" + " --value When showing properties, only print the value\n" + " -i --ignore-inhibitors When shutting down or sleeping, ignore inhibitors\n" + " --kill-who=WHO Whom to send signal to\n" + " -s --signal=SIGNAL Which signal to send\n" + " --what=RESOURCES Which types of resources to remove\n" + " --now Start or stop unit after enabling or disabling it\n" + " --dry-run Only print what would be done\n" + " -q --quiet Suppress output\n" + " --wait For (re)start, wait until service stopped again\n" + " For is-system-running, wait until startup is completed\n" + " --no-block Do not wait until operation finished\n" + " --no-wall Don't send wall message before halt/power-off/reboot\n" + " --no-reload Don't reload daemon after en-/dis-abling unit files\n" + " --no-legend Do not print a legend (column headers and hints)\n" + " --no-pager Do not pipe output into a pager\n" + " --no-ask-password Do not ask for system passwords\n" + " --global Enable/disable/mask unit files globally\n" + " --runtime Enable/disable/mask unit files temporarily until next\n" + " reboot\n" + " -f --force When enabling unit files, override existing symlinks\n" + " When shutting down, execute action immediately\n" + " --preset-mode= Apply only enable, only disable, or all presets\n" + " --root=PATH Enable/disable/mask unit files in the specified root\n" + " directory\n" + " -n --lines=INTEGER Number of journal entries to show\n" + " -o --output=STRING Change journal output mode (short, short-precise,\n" " short-iso, short-iso-precise, short-full,\n" " short-monotonic, short-unix,\n" " verbose, export, json, json-pretty, json-sse, cat)\n" - " --firmware-setup Tell the firmware to show the setup menu on next boot\n" + " --firmware-setup Tell the firmware to show the setup menu on next boot\n" " --boot-loader-menu=TIME\n" - " Boot into boot loader menu on next boot\n" + " Boot into boot loader menu on next boot\n" " --boot-loader-entry=NAME\n" - " Boot into a specific boot loader entry on next boot\n" - " --plain Print unit dependencies as a list instead of a tree\n" + " Boot into a specific boot loader entry on next boot\n" + " --plain Print unit dependencies as a list instead of a tree\n" "\nSee the %2$s for details.\n" , program_invocation_short_name , link