A few times while troubleshooting it would have been useful to get complete logs, rather than post-rate-limiting snapshots of them. These ovs-appctl commands make that possible.
Signed-off-by: Ben Pfaff <b...@nicira.com> --- NEWS | 9 ++++-- lib/vlog-unixctl.man | 22 ++++++++++++++ lib/vlog.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++---- lib/vlog.h | 6 ++- 4 files changed, 103 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index d841cb3..f77232b 100644 --- a/NEWS +++ b/NEWS @@ -3,9 +3,12 @@ post-v1.8.0 - FreeBSD is now a supported platform, thanks to code contributions from Gaetano Catalli, Ed Maste, and Giuseppe Lettieri. - ovs-bugtool: New --ovs option to report only OVS related information. - - New %t and %T log escapes to identify the subprogram within a - cooperating group of processes or threads that emitted a log message. - The default log patterns now include this information. + - Logging: + - New %t and %T log escapes to identify the subprogram within a + cooperating group of processes or threads that emitted a log message. + The default log patterns now include this information. + - New "vlog/disable-rate-limit" and "vlog/enable-rate-limit" commands + available through ovs-appctl allow control over logging rate limits. - OpenFlow: - Allow bitwise masking for SHA and THA fields in ARP, SLL and TLL fields in IPv6 neighbor discovery messages, and IPv6 flow label. diff --git a/lib/vlog-unixctl.man b/lib/vlog-unixctl.man index 567ac0e..4ead3e2 100644 --- a/lib/vlog-unixctl.man +++ b/lib/vlog-unixctl.man @@ -1,3 +1,8 @@ +.de IQ +. br +. ns +. IP "\\$1" +.. .SS "VLOG COMMANDS" These commands manage \fB\*(PN\fR's logging settings. .IP "\fBvlog/set\fR [\fIspec\fR]" @@ -48,3 +53,20 @@ after rotating log files, to cause a new log file to be used.) .IP This has no effect unless \fB\*(PN\fR was invoked with the \fB\-\-log\-file\fR option. +. +.IP "\fBvlog/disable\-rate\-limit \fR[\fImodule\fR]..." +.IQ "\fBvlog/enable\-rate\-limit \fR[\fImodule\fR]..." +By default, \fB\*(PN\fR limits the rate at which certain messages can +be logged. When a message would appear more frequently than the +limit, it is suppressed. This saves disk space, makes logs easier to +read, and speeds up execution, but occasionally troubleshooting +requires more detail. Therefore, \fBvlog/disable\-rate\-limit\fR +allows rate limits to be disabled at the level of an individual log +module. Specify one or more module names, as displayed by the +\fBvlog/list\fR command. Specifying either no module names at all or +the keyword \fBany\fR disables rate limits for every log module. +. +.IP +The \fBvlog/enable\-rate\-limit\fR command, whose syntax is the same +as \fBvlog/disable\-rate\-limit\fR, can be used to re-enable a rate +limit that was previously disabled. diff --git a/lib/vlog.c b/lib/vlog.c index 0bd9bd1..31ba96e 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -480,6 +480,55 @@ vlog_unixctl_reopen(struct unixctl_conn *conn, int argc OVS_UNUSED, } } +static void +set_all_rate_limits(bool enable) +{ + struct vlog_module **mp; + + for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) { + (*mp)->honor_rate_limits = enable; + } +} + +static void +set_rate_limits(struct unixctl_conn *conn, int argc, + const char *argv[], bool enable) +{ + if (argc > 1) { + int i; + + for (i = 1; i < argc; i++) { + if (!strcasecmp(argv[i], "ANY")) { + set_all_rate_limits(enable); + } else { + struct vlog_module *module = vlog_module_from_name(argv[i]); + if (!module) { + unixctl_command_reply_error(conn, "unknown module"); + return; + } + module->honor_rate_limits = enable; + } + } + } else { + set_all_rate_limits(enable); + } + unixctl_command_reply(conn, NULL); +} + +static void +vlog_enable_rate_limit(struct unixctl_conn *conn, int argc, + const char *argv[], void *aux OVS_UNUSED) +{ + set_rate_limits(conn, argc, argv, true); +} + +static void +vlog_disable_rate_limit(struct unixctl_conn *conn, int argc, + const char *argv[], void *aux OVS_UNUSED) +{ + set_rate_limits(conn, argc, argv, false); +} + /* Initializes the logging subsystem and registers its unixctl server * commands. */ void @@ -515,6 +564,10 @@ vlog_init(void) "vlog/set", "{spec | PATTERN:facility:pattern}", 1, INT_MAX, vlog_unixctl_set, NULL); unixctl_command_register("vlog/list", "", 0, 0, vlog_unixctl_list, NULL); + unixctl_command_register("vlog/enable-rate-limit", "[module]...", + 0, INT_MAX, vlog_enable_rate_limit, NULL); + unixctl_command_register("vlog/disable-rate-limit", "[module]...", + 0, INT_MAX, vlog_disable_rate_limit, NULL); unixctl_command_register("vlog/reopen", "", 0, 0, vlog_unixctl_reopen, NULL); } @@ -543,12 +596,20 @@ vlog_get_levels(void) ds_put_format(&s, " ------- ------ ------\n"); for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) { - line = xasprintf("%-16s %4s %4s %4s\n", - vlog_get_module_name(*mp), - vlog_get_level_name(vlog_get_level(*mp, VLF_CONSOLE)), - vlog_get_level_name(vlog_get_level(*mp, VLF_SYSLOG)), - vlog_get_level_name(vlog_get_level(*mp, VLF_FILE))); - svec_add_nocopy(&lines, line); + struct ds line; + + ds_init(&line); + ds_put_format(&line, "%-16s %4s %4s %4s", + vlog_get_module_name(*mp), + vlog_get_level_name(vlog_get_level(*mp, VLF_CONSOLE)), + vlog_get_level_name(vlog_get_level(*mp, VLF_SYSLOG)), + vlog_get_level_name(vlog_get_level(*mp, VLF_FILE))); + if (!(*mp)->honor_rate_limits) { + ds_put_cstr(&line, " (rate limiting disabled)"); + } + ds_put_char(&line, '\n'); + + svec_add_nocopy(&lines, ds_steal_cstr(&line)); } svec_sort(&lines); @@ -826,6 +887,10 @@ bool vlog_should_drop(const struct vlog_module *module, enum vlog_level level, struct vlog_rate_limit *rl) { + if (!module->honor_rate_limits) { + return false; + } + if (!vlog_is_enabled(module, level)) { return true; } diff --git a/lib/vlog.h b/lib/vlog.h index 9570b0e..2595772 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -71,6 +71,7 @@ struct vlog_module { const char *name; /* User-visible name. */ int levels[VLF_N_FACILITIES]; /* Minimum log level for each facility. */ int min_level; /* Minimum log level for any facility. */ + bool honor_rate_limits; /* Set false to ignore rate limits. */ }; /* Creates and initializes a global instance of a module named MODULE. */ @@ -241,9 +242,10 @@ void vlog_usage(void); extern struct vlog_module VLM_##MODULE; \ struct vlog_module VLM_##MODULE = \ { \ - #MODULE, /* name */ \ + #MODULE, /* name */ \ { [ 0 ... VLF_N_FACILITIES - 1] = VLL_INFO }, /* levels */ \ - VLL_INFO, /* min_level */ \ + VLL_INFO, /* min_level */ \ + true /* honor_rate_limits */ \ }; #ifdef __cplusplus -- 1.7.2.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev