From: Willy Tarreau Date: Tue, 15 Sep 2026 11:49:19 +0000 (+0200) Subject: MINOR: stats: report the master and worker IDs in "show info" X-Git-Tag: v3.5-dev7~8 X-Git-Url: https://git.kaiwu.me/$%7BISSUES%7D/static/gitweb.js?a=commitdiff_plain;h=55506fce78e5f9262002fad0fc2ef2e9b3b9f14c;p=haproxy.git MINOR: stats: report the master and worker IDs in "show info" 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. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 47b31639f..1f3a096d4 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -3848,8 +3848,9 @@ worker-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 diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index 57a38c311..2e76750e0 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -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 diff --git a/src/stats.c b/src/stats.c index 9306cb151..f55cf578a 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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; }