From 64a9c05f37b255708056d94fd2852cc7ebba2733 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 12 Apr 2019 15:27:17 +0200 Subject: [PATCH] MINOR: cli/listener: report the number of accepts on "show activity" The "show activity" command reports the number of incoming connections dispatched per thread but doesn't report the number of connections received by each thread. It is important to be able to monitor this value as it can show that for whatever reason a smaller set of threads is receiving the connections and dispatching them to all other ones. --- include/types/activity.h | 1 + src/cli.c | 1 + src/listener.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/include/types/activity.h b/include/types/activity.h index 9cf4e731d0..329513a39e 100644 --- a/include/types/activity.h +++ b/include/types/activity.h @@ -51,6 +51,7 @@ struct activity { struct freq_ctr cpust_1s; // avg amount of half-ms stolen over last second struct freq_ctr_period cpust_15s; // avg amount of half-ms stolen over last 15s unsigned int avg_loop_us; // average run time per loop over last 1024 runs + unsigned int accepted; // accepted incoming connections unsigned int accq_pushed; // accept queue connections pushed unsigned int accq_full; // accept queue connection not pushed because full char __pad[0]; // unused except to check remaining room diff --git a/src/cli.c b/src/cli.c index 96b59e0f4e..755a94c133 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1068,6 +1068,7 @@ static int cli_io_handler_show_activity(struct appctx *appctx) chunk_appendf(&trash, "\ncpust_ms_1s:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr(&activity[thr].cpust_1s)/2); chunk_appendf(&trash, "\ncpust_ms_15s:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr_period(&activity[thr].cpust_15s, 15000)/2); chunk_appendf(&trash, "\navg_loop_us:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", swrate_avg(activity[thr].avg_loop_us, TIME_STATS_SAMPLES)); + chunk_appendf(&trash, "\naccepted:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].accepted); chunk_appendf(&trash, "\naccq_pushed:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].accq_pushed); chunk_appendf(&trash, "\naccq_full:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].accq_full); diff --git a/src/listener.c b/src/listener.c index 619a3cbdba..d8631883ee 100644 --- a/src/listener.c +++ b/src/listener.c @@ -826,6 +826,8 @@ void listener_accept(int fd) HA_ATOMIC_UPDATE_MAX(&global.cps_max, count); } + _HA_ATOMIC_ADD(&activity[tid].accepted, 1); + if (unlikely(cfd >= global.maxsock)) { send_log(p, LOG_EMERG, "Proxy %s reached the configured maximum connection limit. Please check the global 'maxconn' value.\n",