From: Timo Sirainen Date: Mon, 9 Feb 2015 02:03:12 +0000 (+0200) Subject: log: If too much logging data is sent, show it in process title. X-Git-Tag: 2.2.16.rc1~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2880c3c3de56ec757ffc393363bb863efd7bcbe;p=thirdparty%2Fdovecot%2Fcore.git log: If too much logging data is sent, show it in process title. --- diff --git a/src/log/log-connection.c b/src/log/log-connection.c index d1fef194c0..a8a02d2fe5 100644 --- a/src/log/log-connection.c +++ b/src/log/log-connection.c @@ -7,6 +7,7 @@ #include "llist.h" #include "hash.h" #include "time-util.h" +#include "process-title.h" #include "master-interface.h" #include "master-service.h" #include "log-error-buffer.h" @@ -51,9 +52,37 @@ struct log_connection { static struct log_connection *log_connections = NULL; static ARRAY(struct log_connection *) logs_by_fd; +static unsigned int global_pending_count; +static struct log_connection *last_pending_log; static void log_connection_destroy(struct log_connection *log); +static void log_refresh_proctitle(void) +{ + if (!verbose_proctitle) + return; + + if (global_pending_count == 0) + process_title_set(""); + else if (last_pending_log == NULL) { + process_title_set(t_strdup_printf( + "[%u services too fast]", global_pending_count)); + } else if (global_pending_count > 1) { + process_title_set(t_strdup_printf( + "[%u services too fast, last: %d/%d/%s]", + global_pending_count, + last_pending_log->fd, + last_pending_log->listen_fd, + last_pending_log->default_prefix)); + } else { + process_title_set(t_strdup_printf( + "[service too fast: %d/%d/%s]", + last_pending_log->fd, + last_pending_log->listen_fd, + last_pending_log->default_prefix)); + } +} + static struct log_client *log_client_get(struct log_connection *log, pid_t pid) { struct log_client *client; @@ -326,14 +355,26 @@ static void log_connection_input(struct log_connection *log) log_connection_destroy(log); } else { i_assert(!log->input->closed); - if (ret == 0) - log->pending_count = 0; - else if (++log->pending_count >= LOG_WARN_PENDING_COUNT) { - if (log->pending_count == LOG_WARN_PENDING_COUNT || - (log->pending_count % LOG_WARN_PENDING_INTERVAL) == 0) { - i_warning("Log connection fd %d listen_fd %d prefix '%s' is sending input faster than we can write", - log->fd, log->listen_fd, log->default_prefix); + if (ret == 0) { + if (log->pending_count > 0) { + log->pending_count = 0; + i_assert(global_pending_count > 0); + global_pending_count--; + if (log == last_pending_log) + last_pending_log = NULL; + log_refresh_proctitle(); } + return; + } + last_pending_log = log; + if (log->pending_count++ == 0) { + global_pending_count++; + log_refresh_proctitle(); + } + if (log->pending_count == LOG_WARN_PENDING_COUNT || + (log->pending_count % LOG_WARN_PENDING_INTERVAL) == 0) { + i_warning("Log connection fd %d listen_fd %d prefix '%s' is sending input faster than we can write", + log->fd, log->listen_fd, log->default_prefix); } } } diff --git a/src/log/log-connection.h b/src/log/log-connection.h index cfec98bb00..8d2a368a0b 100644 --- a/src/log/log-connection.h +++ b/src/log/log-connection.h @@ -3,6 +3,8 @@ struct log_connection; +extern bool verbose_proctitle; + void log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd); diff --git a/src/log/main.c b/src/log/main.c index 0c99d8d199..216dde2b2b 100644 --- a/src/log/main.c +++ b/src/log/main.c @@ -12,6 +12,7 @@ #include +bool verbose_proctitle; static struct log_error_buffer *errorbuf; static void @@ -71,6 +72,8 @@ int main(int argc, char *argv[]) i_fatal("Error reading configuration: %s", error); master_service_init_log(master_service, "log: "); + verbose_proctitle = master_service_settings_get(master_service)->verbose_proctitle; + restrict_access_by_env(NULL, FALSE); restrict_access_allow_coredumps(TRUE); diff --git a/src/master/service-process.c b/src/master/service-process.c index 6159b0b81e..dbe7fd7fe0 100644 --- a/src/master/service-process.c +++ b/src/master/service-process.c @@ -227,6 +227,8 @@ static void service_process_setup_config_environment(struct service *service) env_put(t_strconcat("DEBUG_LOG_PATH=", set->debug_log_path, NULL)); env_put(t_strconcat("LOG_TIMESTAMP=", set->log_timestamp, NULL)); env_put(t_strconcat("SYSLOG_FACILITY=", set->syslog_facility, NULL)); + if (set->verbose_proctitle) + env_put("VERBOSE_PROCTITLE=1"); env_put("SSL=no"); break; default: