]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: Add TX/RX heartbeat counters.
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 6 Nov 2019 10:51:26 +0000 (11:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2019 13:48:25 +0000 (14:48 +0100)
Add RX/TX heartbeat counters to "peer" struct to have an idead about which
peer is alive or not.
Dump these counters values on the CLI via "show peers" command.

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

index 1d9123d1d89da9c3cf01fbcb4da2c39748796a0e..01b84b16ea0b506cf39f63fdfc11b9d2bae898ae 100644 (file)
@@ -66,6 +66,8 @@ struct peer {
        unsigned int reconnect;       /* next connect timer */
        unsigned int heartbeat;       /* next heartbeat timer */
        unsigned int confirm;         /* confirm message counter */
+       uint32_t rx_hbt;              /* received heartbeats counter */
+       uint32_t tx_hbt;              /* transmitted heartbeats counter */
        struct appctx *appctx;        /* the appctx running it */
        struct shared_table *remote_table;
        struct shared_table *last_local_table;
index 47ca9b1bb91536d16ac1bc0262a73f55b1c33b85..cdc36d3a58660830e9078acfefe06a9d6406ef2c 100644 (file)
@@ -1819,6 +1819,7 @@ static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *pee
                }
                else if (msg_head[1] == PEER_MSG_CTRL_HEARTBEAT) {
                        peer->reconnect = tick_add(now_ms, MS_TO_TICKS(PEER_RECONNECT_TIMEOUT));
+                       peer->rx_hbt++;
                }
        }
        else if (msg_head[0] == PEER_MSG_CLASS_STICKTABLE) {
@@ -2371,6 +2372,7 @@ send_msgs:
                                                        goto out;
                                                goto switchstate;
                                        }
+                                       curpeer->tx_hbt++;
                                }
                                /* we get here when a peer_recv_msg() returns 0 in reql */
                                repl = peer_send_msgs(appctx, curpeer);
@@ -3066,7 +3068,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\n",
+       chunk_appendf(msg, "  %p: id=%s(%s) addr=%s:%d status=%s reconnect=%s confirm=%u tx_hbt=%u rx_hbt=%u\n",
                      peer, peer->id,
                      peer->local ? "local" : "remote",
                      pn, get_host_port(&peer->addr),
@@ -3075,7 +3077,7 @@ 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->confirm, peer->tx_hbt, peer->rx_hbt);
 
        chunk_appendf(&trash, "        flags=0x%x", peer->flags);