mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: stream/stats: Expose the current number of streams in stats
A shared counter is added in the thread context to track the current number of streams. This number is then reported in stats. It will be a useful information to diagnose some bugs.
This commit is contained in:
parent
6a94b7419e
commit
18ee22ff76
@ -334,6 +334,7 @@ enum stat_idx_info {
|
|||||||
ST_I_INF_MAXCONN_REACHED,
|
ST_I_INF_MAXCONN_REACHED,
|
||||||
ST_I_INF_BOOTTIME_MS,
|
ST_I_INF_BOOTTIME_MS,
|
||||||
ST_I_INF_NICED_TASKS,
|
ST_I_INF_NICED_TASKS,
|
||||||
|
ST_I_INF_CURR_STRM,
|
||||||
|
|
||||||
/* must always be the last one */
|
/* must always be the last one */
|
||||||
ST_I_INF_MAX
|
ST_I_INF_MAX
|
||||||
|
@ -180,7 +180,9 @@ struct thread_ctx {
|
|||||||
unsigned long long out_bytes; /* total #of bytes emitted */
|
unsigned long long out_bytes; /* total #of bytes emitted */
|
||||||
unsigned long long spliced_out_bytes; /* total #of bytes emitted though a kernel pipe */
|
unsigned long long spliced_out_bytes; /* total #of bytes emitted though a kernel pipe */
|
||||||
struct buffer *thread_dump_buffer; /* NULL out of dump, valid during a dump, 0x01 once done */
|
struct buffer *thread_dump_buffer; /* NULL out of dump, valid during a dump, 0x01 once done */
|
||||||
// around 64 bytes here for shared variables
|
unsigned int stream_cnt; /* Number of streams attached to this thread */
|
||||||
|
|
||||||
|
// around 52 bytes here for shared variables
|
||||||
|
|
||||||
ALWAYS_ALIGN(128);
|
ALWAYS_ALIGN(128);
|
||||||
};
|
};
|
||||||
|
@ -168,6 +168,7 @@ const struct name_desc stat_cols_info[ST_I_INF_MAX] = {
|
|||||||
[ST_I_INF_MAXCONN_REACHED] = { .name = "MaxconnReached", .desc = "Number of times an accepted connection resulted in Maxconn being reached" },
|
[ST_I_INF_MAXCONN_REACHED] = { .name = "MaxconnReached", .desc = "Number of times an accepted connection resulted in Maxconn being reached" },
|
||||||
[ST_I_INF_BOOTTIME_MS] = { .name = "BootTime_ms", .desc = "How long ago it took to parse and process the config before being ready (milliseconds)" },
|
[ST_I_INF_BOOTTIME_MS] = { .name = "BootTime_ms", .desc = "How long ago it took to parse and process the config before being ready (milliseconds)" },
|
||||||
[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_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" },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* one line of info */
|
/* one line of info */
|
||||||
@ -691,7 +692,7 @@ static int stats_dump_typed_info_fields(struct buffer *out,
|
|||||||
int stats_fill_info(struct field *line, int len, uint flags)
|
int stats_fill_info(struct field *line, int len, uint flags)
|
||||||
{
|
{
|
||||||
struct buffer *out = get_trash_chunk();
|
struct buffer *out = get_trash_chunk();
|
||||||
uint64_t glob_out_bytes, glob_spl_bytes, glob_out_b32;
|
uint64_t glob_out_bytes, glob_spl_bytes, glob_out_b32, glob_curr_strms;
|
||||||
uint up_sec, up_usec;
|
uint up_sec, up_usec;
|
||||||
ullong up;
|
ullong up;
|
||||||
ulong boot;
|
ulong boot;
|
||||||
@ -707,11 +708,12 @@ int stats_fill_info(struct field *line, int len, uint flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sum certain per-thread totals (mostly byte counts) */
|
/* sum certain per-thread totals (mostly byte counts) */
|
||||||
glob_out_bytes = glob_spl_bytes = glob_out_b32 = 0;
|
glob_out_bytes = glob_spl_bytes = glob_out_b32 = glob_curr_strms = 0;
|
||||||
for (thr = 0; thr < global.nbthread; thr++) {
|
for (thr = 0; thr < global.nbthread; thr++) {
|
||||||
glob_out_bytes += HA_ATOMIC_LOAD(&ha_thread_ctx[thr].out_bytes);
|
glob_out_bytes += HA_ATOMIC_LOAD(&ha_thread_ctx[thr].out_bytes);
|
||||||
glob_spl_bytes += HA_ATOMIC_LOAD(&ha_thread_ctx[thr].spliced_out_bytes);
|
glob_spl_bytes += HA_ATOMIC_LOAD(&ha_thread_ctx[thr].spliced_out_bytes);
|
||||||
glob_out_b32 += read_freq_ctr(&ha_thread_ctx[thr].out_32bps);
|
glob_out_b32 += read_freq_ctr(&ha_thread_ctx[thr].out_32bps);
|
||||||
|
glob_curr_strms+= HA_ATOMIC_LOAD(&ha_thread_ctx[thr].stream_cnt);
|
||||||
}
|
}
|
||||||
glob_out_b32 *= 32; // values are 32-byte units
|
glob_out_b32 *= 32; // values are 32-byte units
|
||||||
|
|
||||||
@ -817,6 +819,7 @@ int stats_fill_info(struct field *line, int len, uint flags)
|
|||||||
line[ST_I_INF_MAXCONN_REACHED] = mkf_u32(FN_COUNTER, HA_ATOMIC_LOAD(&maxconn_reached));
|
line[ST_I_INF_MAXCONN_REACHED] = mkf_u32(FN_COUNTER, HA_ATOMIC_LOAD(&maxconn_reached));
|
||||||
line[ST_I_INF_BOOTTIME_MS] = mkf_u32(FN_DURATION, boot);
|
line[ST_I_INF_BOOTTIME_MS] = mkf_u32(FN_DURATION, boot);
|
||||||
line[ST_I_INF_NICED_TASKS] = mkf_u32(0, total_niced_running_tasks());
|
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);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -546,6 +546,7 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
|
|||||||
s->tunnel_timeout = TICK_ETERNITY;
|
s->tunnel_timeout = TICK_ETERNITY;
|
||||||
|
|
||||||
LIST_APPEND(&th_ctx->streams, &s->list);
|
LIST_APPEND(&th_ctx->streams, &s->list);
|
||||||
|
_HA_ATOMIC_INC(&th_ctx->stream_cnt);
|
||||||
|
|
||||||
if (flt_stream_init(s) < 0 || flt_stream_start(s) < 0)
|
if (flt_stream_init(s) < 0 || flt_stream_start(s) < 0)
|
||||||
goto out_fail_accept;
|
goto out_fail_accept;
|
||||||
@ -716,6 +717,7 @@ void stream_free(struct stream *s)
|
|||||||
__ha_barrier_store();
|
__ha_barrier_store();
|
||||||
}
|
}
|
||||||
LIST_DELETE(&s->list);
|
LIST_DELETE(&s->list);
|
||||||
|
_HA_ATOMIC_DEC(&th_ctx->stream_cnt);
|
||||||
|
|
||||||
sc_destroy(s->scb);
|
sc_destroy(s->scb);
|
||||||
sc_destroy(s->scf);
|
sc_destroy(s->scf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user