]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: stats: report the master and worker IDs in "show info"
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Sep 2026 11:49:19 +0000 (13:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2026 16:00:51 +0000 (18:00 +0200)
Two new fields, "Master_id" and "Worker_id", are now reported by the CLI
command "show info".

The master's one is only emitted in master-worker mode, as is already done
for the "description" field.

doc/configuration.txt
include/haproxy/stats-t.h
src/stats.c

index 47b31639fbdf079226a7e01816e5e80390c16648..1f3a096d4b4970af94e9242350b1832e231dfe68 100644 (file)
@@ -3848,8 +3848,9 @@ worker-id <id>
       worker-id "pop7-node1-inst3-${HAPROXY_WORKER_ID}"
 
   The identifier is exported as the HAPROXY_WORKER_ID environment variable (see
-  section 2.3) and is returned by the "worker_id" sample fetch function. See
-  also HAPROXY_MASTER_ID in section 2.3, and the "worker_id" sample fetch
+  section 2.3), is returned by the "worker_id" sample fetch function and on the
+  output of the "show info" CLI command. See also the "HAPROXY_MASTER_ID"
+  environment variable in section 2.3, and the "worker_id" sample fetch
   function.
 
 wurfl-cache-size <size>
index 57a38c311d7d5f74d2f44daa91e9aa24fb64c494..2e76750e098dba1c00398a91d4bd472b9923320b 100644 (file)
@@ -341,6 +341,8 @@ enum stat_idx_info {
        ST_I_INF_PATTERNS_ADDED,
        ST_I_INF_PATTERNS_FREED,
        ST_I_INF_NBTGROUPS,
+       ST_I_INF_MASTER_ID,
+       ST_I_INF_WORKER_ID,
 
        /* must always be the last one */
        ST_I_INF_MAX
index 9306cb1512a7b5d1c11163aa377d49f3480a4731..f55cf578a6c4f1ef899404385c8af0919ae4daaa 100644 (file)
@@ -175,6 +175,8 @@ const struct stat_col stat_cols_info[ST_I_INF_MAX] = {
        [ST_I_INF_PATTERNS_ADDED]                 = { .name = "PatternsAdded",               .alt_name = "patterns_added_total",          .desc = "Total number of patterns added (acl/map entries)" },
        [ST_I_INF_PATTERNS_FREED]                 = { .name = "PatternsFreed",               .alt_name = "patterns_freed_total",          .desc = "Total number of patterns freed (acl/map entries)" },
        [ST_I_INF_NBTGROUPS]                      = { .name = "NbThreadGroups",              .alt_name = "nb_thread_groups",              .desc = "Number of started thread groups (global.thread-groups)" },
+       [ST_I_INF_MASTER_ID]                      = { .name = "Master_id",                   .alt_name = "master_id",                     .desc = "Unique identifier of the master process, preserved across reloads (master-worker mode only)" },
+       [ST_I_INF_WORKER_ID]                      = { .name = "Worker_id",                   .alt_name = "worker_id",                     .desc = "Unique identifier of this worker process, renewed on each reload unless set with global 'worker-id'" },
 };
 
 /* one line of info */
@@ -844,6 +846,10 @@ int stats_fill_info(struct field *line, int len, uint flags)
        line[ST_I_INF_PATTERNS_FREED]                 = mkf_u64(0, patterns_freed);
        line[ST_I_INF_NBTGROUPS]                      = mkf_u32(FO_CONFIG|FS_SERVICE, global.nbtgroups);
 
+       if (global.master_id)
+               line[ST_I_INF_MASTER_ID]              = mkf_str(FO_CONFIG|FN_OUTPUT|FS_SERVICE, global.master_id);
+       if (global.worker_id)
+               line[ST_I_INF_WORKER_ID]              = mkf_str(FO_CONFIG|FN_OUTPUT|FS_SERVICE, global.worker_id);
        return 1;
 }