From: Frédéric Lécaille Date: Wed, 6 Nov 2019 10:51:26 +0000 (+0100) Subject: MINOR: peers: Add TX/RX heartbeat counters. X-Git-Tag: v2.1.0~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33cab3c0eba13d125242a8d1a5696f3f47ea1e32;p=thirdparty%2Fhaproxy.git MINOR: peers: Add TX/RX heartbeat counters. 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. --- diff --git a/include/types/peers.h b/include/types/peers.h index 1d9123d1d8..01b84b16ea 100644 --- a/include/types/peers.h +++ b/include/types/peers.h @@ -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; diff --git a/src/peers.c b/src/peers.c index 47ca9b1bb9..cdc36d3a58 100644 --- a/src/peers.c +++ b/src/peers.c @@ -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) ? "" : human_time(TICKS_TO_MS(peer->reconnect - now_ms), TICKS_TO_MS(1000)) : "", - peer->confirm); + peer->confirm, peer->tx_hbt, peer->rx_hbt); chunk_appendf(&trash, " flags=0x%x", peer->flags);