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.
diff --git a/include/types/peers.h b/include/types/peers.h
index 01b84b1..89962a3 100644
--- a/include/types/peers.h
+++ b/include/types/peers.h
@@ -68,6 +68,9 @@
unsigned int confirm; /* confirm message counter */
uint32_t rx_hbt; /* received 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 shared_table *remote_table;
struct shared_table *last_local_table;
diff --git a/src/peers.c b/src/peers.c
index cdc36d3..4736945 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -2403,6 +2403,8 @@
goto switchstate;
}
case PEER_SESS_ST_ERRPROTO: {
+ if (curpeer)
+ curpeer->proto_err++;
if (prev_state == PEER_SESS_ST_WAITMSG)
_HA_ATOMIC_SUB(&connected_peers, 1);
prev_state = appctx->st0;
@@ -2616,6 +2618,7 @@
/* reschedule task for reconnect */
task->expire = tick_first(task->expire, ps->reconnect);
+ ps->new_conn++;
}
/* else do nothing */
} /* !ps->appctx */
@@ -2674,6 +2677,7 @@
else {
ps->reconnect = tick_add(now_ms, MS_TO_TICKS(50 + random() % 2000));
peer_session_forceshutdown(ps);
+ ps->no_hbt++;
}
}
else if (tick_is_expired(ps->heartbeat, now_ms)) {
@@ -3068,7 +3072,7 @@
struct shared_table *st;
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->local ? "local" : "remote",
pn, get_host_port(&peer->addr),
@@ -3077,7 +3081,8 @@
tick_is_expired(peer->reconnect, now_ms) ? "<PAST>" :
human_time(TICKS_TO_MS(peer->reconnect - now_ms),
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);