]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: report the number of active jobs and listeners in "show info"
authorWilly Tarreau <w@1wt.eu>
Mon, 5 Nov 2018 13:38:13 +0000 (14:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 5 Nov 2018 16:15:21 +0000 (17:15 +0100)
When an haproxy process doesn't stop after a reload, it's because it
still has some active "jobs", which mainly are active sessions, listeners,
peers or other specific activities. Sometimes it's difficult to troubleshoot
the cause of these issues (which generally are the result of a bug) only
because some indicators are missing.

This patch add the number of listeners, the number of jobs, and the stopping
status to the output of "show info". This way it becomes a bit easier to try
to narrow down the cause of such an issue should it happen. A typical use
case is to connect to the CLI before reloading, then issuing the "show info"
command to see what happens. In the normal situation, stopping should equal
1, jobs should equal 1 (meaning only the CLI is still active) and listeners
should equal zero.

The patch is so trivial that it could make sense to backport it to 1.8 in
order to help with troubleshooting.

include/types/stats.h
src/stats.c

index a22be365e3cfa10b1bbac7d6aa0ae32a48d8a2fb..8df848978ddc9cd1bdde222b66521e54e444f0c2 100644 (file)
@@ -288,6 +288,9 @@ enum info_field {
        INF_IDLE_PCT,
        INF_NODE,
        INF_DESCRIPTION,
+       INF_STOPPING,
+       INF_JOBS,
+       INF_LISTENERS,
 
        /* must always be the last one */
        INF_TOTAL_FIELDS
index efa5c090c33ed672a32df28f7dc68723193ec16b..cbb9870024149ed7ace2d1c137718cc087d555b9 100644 (file)
@@ -130,6 +130,9 @@ const char *info_field_names[INF_TOTAL_FIELDS] = {
        [INF_IDLE_PCT]                       = "Idle_pct",
        [INF_NODE]                           = "node",
        [INF_DESCRIPTION]                    = "description",
+       [INF_STOPPING]                       = "Stopping",
+       [INF_JOBS]                           = "Jobs",
+       [INF_LISTENERS]                      = "Listeners",
 };
 
 const char *stat_field_names[ST_F_TOTAL_FIELDS] = {
@@ -3292,6 +3295,9 @@ int stats_fill_info(struct field *info, int len)
        info[INF_NODE]                           = mkf_str(FO_CONFIG|FN_OUTPUT|FS_SERVICE, global.node);
        if (global.desc)
                info[INF_DESCRIPTION]            = mkf_str(FO_CONFIG|FN_OUTPUT|FS_SERVICE, global.desc);
+       info[INF_STOPPING]                       = mkf_u32(0, stopping);
+       info[INF_JOBS]                           = mkf_u32(0, jobs);
+       info[INF_LISTENERS]                      = mkf_u32(0, listeners);
 
        return 1;
 }