summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-11-13 20:20:10 +0100
committerGitHub <noreply@github.com>2019-11-13 20:20:10 +0100
commita53c38f1a22f41603ddc36c54359dd9bb7b15378 (patch)
tree509b9052c7fe4cec58c2a5cce1ff63d6994bfc32
parenta650e19820b85e7b82a87508a7f80ce764f2f1a0 (diff)
parentd816a5fcead33df9dedddce3769341436a30119e (diff)
downloadsystemd-a53c38f1a22f41603ddc36c54359dd9bb7b15378.tar.gz
systemd-a53c38f1a22f41603ddc36c54359dd9bb7b15378.tar.bz2
systemd-a53c38f1a22f41603ddc36c54359dd9bb7b15378.zip
Merge pull request #14017 from poettering/analyze-calendar-tweaks
Add --base-time= for systemd-analyze calendar
-rw-r--r--TODO2
-rw-r--r--man/systemd-analyze.xml7
-rw-r--r--src/analyze/analyze.c17
3 files changed, 24 insertions, 2 deletions
diff --git a/TODO b/TODO
index a7bc74975d..8e2e502c46 100644
--- a/TODO
+++ b/TODO
@@ -37,6 +37,8 @@ Features:
may be used to mark a whole binary as non-coredumpable. Would fix:
https://bugs.freedesktop.org/show_bug.cgi?id=69447
+* teach parse_timestamp() timezones like the calendar spec already knows it
+
* beef up hibernation to optionally do swapon/swapoff immediately before/after
the hibernation
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index 7e842ac201..02d7179e4c 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -778,6 +778,13 @@ Service b@0.service not loaded, b.socket cannot be started.
iterations the specified calendar expression will elapse next. Defaults to 1.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--base-time=<replaceable>TIMESTAMP</replaceable></option></term>
+
+ <listitem><para>When used with the <command>calendar</command> command, show next iterations relative
+ to the specified point in time. If not specified defaults to the current time.</para></listitem>
+ </varlistentry>
+
<xi:include href="user-system-options.xml" xpointer="host" />
<xi:include href="user-system-options.xml" xpointer="machine" />
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 9972941520..9421196fff 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -84,6 +84,7 @@ static bool arg_man = true;
static bool arg_generators = false;
static const char *arg_root = NULL;
static unsigned arg_iterations = 1;
+static usec_t arg_base_time = USEC_INFINITY;
STATIC_DESTRUCTOR_REGISTER(arg_dot_from_patterns, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_dot_to_patterns, strv_freep);
@@ -2136,7 +2137,10 @@ static int test_calendar(int argc, char *argv[], void *userdata) {
char **p;
usec_t n;
- n = now(CLOCK_REALTIME); /* We want to use the same "base" for all expressions */
+ if (arg_base_time != USEC_INFINITY)
+ n = arg_base_time;
+ else
+ n = now(CLOCK_REALTIME); /* We want to use the same "base" for all expressions */
STRV_FOREACH(p, strv_skip(argv, 1)) {
r = test_calendar_one(n, *p);
@@ -2258,6 +2262,7 @@ static int help(int argc, char *argv[], void *userdata) {
" --man[=BOOL] Do [not] check for existence of man pages\n"
" --generators[=BOOL] Do [not] run unit generators (requires privileges)\n"
" --iterations=N Show the specified number of iterations\n"
+ " --base-time=TIMESTAMP Calculate calendar times relative to specified time\n"
"\nCommands:\n"
" time Print time spent in the kernel\n"
" blame Print list of running units ordered by time to init\n"
@@ -2307,6 +2312,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_MAN,
ARG_GENERATORS,
ARG_ITERATIONS,
+ ARG_BASE_TIME,
};
static const struct option options[] = {
@@ -2327,6 +2333,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "host", required_argument, NULL, 'H' },
{ "machine", required_argument, NULL, 'M' },
{ "iterations", required_argument, NULL, ARG_ITERATIONS },
+ { "base-time", required_argument, NULL, ARG_BASE_TIME },
{}
};
@@ -2433,6 +2440,13 @@ static int parse_argv(int argc, char *argv[]) {
break;
+ case ARG_BASE_TIME:
+ r = parse_timestamp(optarg, &arg_base_time);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse --base-time= parameter: %s", optarg);
+
+ break;
+
case '?':
return -EINVAL;
@@ -2472,7 +2486,6 @@ static int run(int argc, char *argv[]) {
{ "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 },
-
{ "dump", VERB_ANY, 1, 0, dump },
{ "cat-config", 2, VERB_ANY, 0, cat_config },
{ "unit-files", VERB_ANY, VERB_ANY, 0, do_unit_files },