diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-17 10:00:52 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-21 09:56:41 +0200 |
commit | c269607f9b77a529372b423dd89f1e5cbc30f3ae (patch) | |
tree | c0f39ef028c00dfaa314481e77835787dc8002c6 /src/analyze | |
parent | a6a67f71bb332611b58c127999e04a4bd2d3298a (diff) | |
download | systemd-c269607f9b77a529372b423dd89f1e5cbc30f3ae.tar.gz systemd-c269607f9b77a529372b423dd89f1e5cbc30f3ae.tar.bz2 systemd-c269607f9b77a529372b423dd89f1e5cbc30f3ae.zip |
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.
Diffstat (limited to 'src/analyze')
-rw-r--r-- | src/analyze/analyze.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index d0b313bdb3..b23dcf7240 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1673,6 +1673,18 @@ static int dump_syscall_filters(int argc, char *argv[], void *userdata) { } #endif +static void parsing_hint(const char *p, bool calendar, bool timestamp, bool timespan) { + if (calendar && calendar_spec_from_string(p, NULL) >= 0) + log_notice("Hint: this expression is a valid calendar specification. " + "Use 'systemd-analyze calendar \"%s\"' instead?", p); + if (timestamp && parse_timestamp(p, NULL) >= 0) + log_notice("Hint: this expression is a valid timestamp. " + "Use 'systemd-analyze timestamp \"%s\"' instead?", p); + if (timespan && parse_time(p, NULL, USEC_PER_SEC) >= 0) + log_notice("Hint: this expression is a valid timespan. " + "Use 'systemd-analyze timespan \"%s\"' instead?", p); +} + static int dump_timespan(int argc, char *argv[], void *userdata) { char **input_timespan; @@ -1682,8 +1694,11 @@ static int dump_timespan(int argc, char *argv[], void *userdata) { char ft_buf[FORMAT_TIMESPAN_MAX]; r = parse_time(*input_timespan, &output_usecs, USEC_PER_SEC); - if (r < 0) - return log_error_errno(r, "Failed to parse time span '%s': %m", *input_timespan); + if (r < 0) { + log_error_errno(r, "Failed to parse time span '%s': %m", *input_timespan); + parsing_hint(*input_timespan, true, true, false); + return r; + } printf("Original: %s\n", *input_timespan); printf(" %ss: %" PRIu64 "\n", special_glyph(SPECIAL_GLYPH_MU), output_usecs); @@ -1705,8 +1720,11 @@ static int test_timestamp_one(const char *p) { int r; r = parse_timestamp(p, &usec); - if (r < 0) - return log_error_errno(r, "Failed to parse \"%s\": %m", p); + if (r < 0) { + log_error_errno(r, "Failed to parse \"%s\": %m", p); + parsing_hint(p, true, false, true); + return r; + } printf(" Original form: %s\n", p); printf("Normalized form: %s%s%s\n", @@ -1744,8 +1762,11 @@ static int test_calendar_one(usec_t n, const char *p) { int r; r = calendar_spec_from_string(p, &spec); - if (r < 0) - return log_error_errno(r, "Failed to parse calendar specification '%s': %m", p); + if (r < 0) { + log_error_errno(r, "Failed to parse calendar specification '%s': %m", p); + parsing_hint(p, false, true, true); + return r; + } r = calendar_spec_to_string(spec, &t); if (r < 0) |