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 1d9123d..01b84b1 100644
--- a/include/types/peers.h
+++ b/include/types/peers.h
@@ -66,6 +66,8 @@
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 47ca9b1..cdc36d3 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1819,6 +1819,7 @@
}
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 @@
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 @@
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 @@
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);