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.

(cherry picked from commit ec1c10b8391b5d1b54de2e95f9c170c9016fe680)
Signed-off-by: Willy Tarreau <w@1wt.eu>
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 309ebae..12fd29a 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -2404,6 +2404,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;
@@ -2641,6 +2643,7 @@
 
 						/* reschedule task for reconnect */
 						task->expire = tick_first(task->expire, ps->reconnect);
+						ps->new_conn++;
 					}
 					/* else do nothing */
 				} /* !ps->appctx */
@@ -2699,6 +2702,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)) {
@@ -3097,7 +3101,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),
@@ -3106,7 +3110,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);