MINOR: peers: Add debugging information to "show peers".

This patch adds three counters to help in debugging peers protocol issues
to "peer" struct:
	->no_hbt counts the number of reconnection period without receiving heartbeat
	->new_conn counts the number of reconnections after ->reconnect timeout expirations.
	->proto_err counts the number of protocol errors.
This commit is contained in:
Frdric Lcaille 2019-11-07 15:22:33 +01:00 committed by Willy Tarreau
parent 33cab3c0eb
commit ec1c10b839
2 changed files with 10 additions and 2 deletions

View File

@ -68,6 +68,9 @@ struct peer {
unsigned int confirm; /* confirm message counter */ unsigned int confirm; /* confirm message counter */
uint32_t rx_hbt; /* received heartbeats counter */ uint32_t rx_hbt; /* received heartbeats counter */
uint32_t tx_hbt; /* transmitted heartbeats counter */ uint32_t tx_hbt; /* transmitted heartbeats counter */
uint32_t no_hbt; /* no received heartbeat counter */
uint32_t new_conn; /* new connection after reconnection timeout expiration counter */
uint32_t proto_err; /* protocol errors counter */
struct appctx *appctx; /* the appctx running it */ struct appctx *appctx; /* the appctx running it */
struct shared_table *remote_table; struct shared_table *remote_table;
struct shared_table *last_local_table; struct shared_table *last_local_table;

View File

@ -2403,6 +2403,8 @@ send_msgs:
goto switchstate; goto switchstate;
} }
case PEER_SESS_ST_ERRPROTO: { case PEER_SESS_ST_ERRPROTO: {
if (curpeer)
curpeer->proto_err++;
if (prev_state == PEER_SESS_ST_WAITMSG) if (prev_state == PEER_SESS_ST_WAITMSG)
_HA_ATOMIC_SUB(&connected_peers, 1); _HA_ATOMIC_SUB(&connected_peers, 1);
prev_state = appctx->st0; prev_state = appctx->st0;
@ -2616,6 +2618,7 @@ static struct task *process_peer_sync(struct task * task, void *context, unsigne
/* reschedule task for reconnect */ /* reschedule task for reconnect */
task->expire = tick_first(task->expire, ps->reconnect); task->expire = tick_first(task->expire, ps->reconnect);
ps->new_conn++;
} }
/* else do nothing */ /* else do nothing */
} /* !ps->appctx */ } /* !ps->appctx */
@ -2674,6 +2677,7 @@ static struct task *process_peer_sync(struct task * task, void *context, unsigne
else { else {
ps->reconnect = tick_add(now_ms, MS_TO_TICKS(50 + random() % 2000)); ps->reconnect = tick_add(now_ms, MS_TO_TICKS(50 + random() % 2000));
peer_session_forceshutdown(ps); peer_session_forceshutdown(ps);
ps->no_hbt++;
} }
} }
else if (tick_is_expired(ps->heartbeat, now_ms)) { else if (tick_is_expired(ps->heartbeat, now_ms)) {
@ -3068,7 +3072,7 @@ static int peers_dump_peer(struct buffer *msg, struct stream_interface *si, stru
struct shared_table *st; struct shared_table *st;
addr_to_str(&peer->addr, pn, sizeof pn); addr_to_str(&peer->addr, pn, sizeof pn);
chunk_appendf(msg, " %p: id=%s(%s) addr=%s:%d status=%s reconnect=%s confirm=%u tx_hbt=%u rx_hbt=%u\n", chunk_appendf(msg, " %p: id=%s(%s) addr=%s:%d status=%s reconnect=%s confirm=%u tx_hbt=%u rx_hbt=%u no_hbt=%u new_conn=%u proto_err=%u\n",
peer, peer->id, peer, peer->id,
peer->local ? "local" : "remote", peer->local ? "local" : "remote",
pn, get_host_port(&peer->addr), pn, get_host_port(&peer->addr),
@ -3077,7 +3081,8 @@ static int peers_dump_peer(struct buffer *msg, struct stream_interface *si, stru
tick_is_expired(peer->reconnect, now_ms) ? "<PAST>" : tick_is_expired(peer->reconnect, now_ms) ? "<PAST>" :
human_time(TICKS_TO_MS(peer->reconnect - now_ms), human_time(TICKS_TO_MS(peer->reconnect - now_ms),
TICKS_TO_MS(1000)) : "<NEVER>", TICKS_TO_MS(1000)) : "<NEVER>",
peer->confirm, peer->tx_hbt, peer->rx_hbt); peer->confirm, peer->tx_hbt, peer->rx_hbt,
peer->no_hbt, peer->new_conn, peer->proto_err);
chunk_appendf(&trash, " flags=0x%x", peer->flags); chunk_appendf(&trash, " flags=0x%x", peer->flags);