]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
log: If too much logging data is sent, show it in process title.
authorTimo Sirainen <tss@iki.fi>
Mon, 9 Feb 2015 02:03:12 +0000 (04:03 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 9 Feb 2015 02:03:12 +0000 (04:03 +0200)
src/log/log-connection.c
src/log/log-connection.h
src/log/main.c
src/master/service-process.c

index d1fef194c093e1d651beae8f346318071ffa0c13..a8a02d2fe5a8072d1d7f4b63884dde5000111a18 100644 (file)
@@ -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);
                }
        }
 }
index cfec98bb007a050a81f969ca9adae487e0a29e05..8d2a368a0b2f2388f127720978a2f4205743e27b 100644 (file)
@@ -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);
 
index 0c99d8d19935682ceacef531dfca0d6b56f4c09e..216dde2b2b4d5272d1702c2dc6a81ad088f0c39f 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <unistd.h>
 
+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);
 
index 6159b0b81e12d4976c48b58defd4efd32bbcb713..dbe7fd7fe0cc555263fd0302beccaf275d22c692 100644 (file)
@@ -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: