]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: Add debugging information to "show peers".
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 7 Nov 2019 14:22:33 +0000 (15:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2019 13:48:28 +0000 (14:48 +0100)
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.

include/types/peers.h
src/peers.c

index 01b84b16ea0b506cf39f63fdfc11b9d2bae898ae..89962a37b55d27aedcd46b414d58653e547925d5 100644 (file)
@@ -68,6 +68,9 @@ struct peer {
        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;
index cdc36d3a58660830e9078acfefe06a9d6406ef2c..473694501f086f9c4239c6ff77b3dffa2801438f 100644 (file)
@@ -2403,6 +2403,8 @@ send_msgs:
                                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 @@ static struct task *process_peer_sync(struct task * task, void *context, unsigne
 
                                                /* reschedule task for reconnect */
                                                task->expire = tick_first(task->expire, ps->reconnect);
+                                               ps->new_conn++;
                                        }
                                        /* else do nothing */
                                } /* !ps->appctx */
@@ -2674,6 +2677,7 @@ static struct task *process_peer_sync(struct task * task, void *context, unsigne
                                                                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 @@ static int peers_dump_peer(struct buffer *msg, struct stream_interface *si, stru
        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 @@ static int peers_dump_peer(struct buffer *msg, struct stream_interface *si, stru
                                     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);