]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: wdt: add a stats counter "BlockedTrafficWarnings" in show info
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Nov 2024 17:10:01 +0000 (18:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Nov 2024 17:35:42 +0000 (18:35 +0100)
Every time a warning is issued about traffic being blocked, let's
increment a global counter so that we can check for this situation
in "show info".

include/haproxy/debug.h
include/haproxy/stats-t.h
src/debug.c
src/stats.c

index 4bdec78da60d275baec8dc774203ee1a2c204fa9..9feed8a99d7afab933e6163445e318829d1eb398 100644 (file)
@@ -25,6 +25,8 @@
 struct task;
 struct buffer;
 extern unsigned int debug_commands_issued;
+extern unsigned int warn_blocked_issued;
+
 void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx);
 void ha_thread_dump_one(int thr, int from_signal);
 void ha_dump_backtrace(struct buffer *buf, const char *prefix, int dump);
index 3af6719d48ad86b34a7b41dc6b42132d41577e3f..c58f1aa65eb5c79410b84a558f7d2ecf4dc7b249 100644 (file)
@@ -336,6 +336,7 @@ enum stat_idx_info {
        ST_I_INF_NICED_TASKS,
        ST_I_INF_CURR_STRM,
        ST_I_INF_CUM_STRM,
+       ST_I_INF_WARN_BLOCKED,
 
        /* must always be the last one */
        ST_I_INF_MAX
index 75307dd7bea5332c282755b5d311f59034fcd08d..37f5c8d3cc58ceded5af3226a84020110f8d2cdc 100644 (file)
@@ -162,6 +162,7 @@ struct post_mortem {
 } post_mortem ALIGNED(256) HA_SECTION("_post_mortem") = { };
 
 unsigned int debug_commands_issued = 0;
+unsigned int warn_blocked_issued = 0;
 
 /* dumps a backtrace of the current thread that is appended to buffer <buf>.
  * Lines are prefixed with the string <prefix> which may be empty (used for
@@ -747,6 +748,8 @@ void ha_stuck_warning(int thr)
                return;
        }
 
+       HA_ATOMIC_INC(&warn_blocked_issued);
+
        buf = b_make(msg_buf, sizeof(msg_buf), 0, 0);
 
        p = HA_ATOMIC_LOAD(&ha_thread_ctx[thr].prev_cpu_time);
index e54141cc00bd56df7d81a679c1c7327c69ab4205..c3f26b085dd9aca0f984b2f0ff9634a2528a2d1c 100644 (file)
@@ -170,6 +170,7 @@ const struct name_desc stat_cols_info[ST_I_INF_MAX] = {
        [ST_I_INF_NICED_TASKS]                    = { .name = "Niced_tasks",                 .desc = "Total number of active tasks+tasklets in the current worker process (Run_queue) that are niced" },
        [ST_I_INF_CURR_STRM]                      = { .name = "CurrStreams",                 .desc = "Current number of streams on this worker process" },
        [ST_I_INF_CUM_STRM]                       = { .name = "CumStreams",                  .desc = "Total number of streams created on this worker process since started" },
+       [ST_I_INF_WARN_BLOCKED]                   = { .name = "BlockedTrafficWarnings",      .desc = "Total number of warnings issued about traffic being blocked by too slow a task" },
 };
 
 /* one line of info */
@@ -823,6 +824,7 @@ int stats_fill_info(struct field *line, int len, uint flags)
        line[ST_I_INF_NICED_TASKS]                    = mkf_u32(0, total_niced_running_tasks());
        line[ST_I_INF_CURR_STRM]                      = mkf_u64(0, glob_curr_strms);
        line[ST_I_INF_CUM_STRM]                       = mkf_u64(0, glob_cum_strms);
+       line[ST_I_INF_WARN_BLOCKED]                   = mkf_u32(0, warn_blocked_issued);
 
        return 1;
 }