From ac099aa272a05ddf0d254e06c1cddb0fbc7884f8 Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Mon, 30 Sep 2019 07:30:30 +0200 Subject: [PATCH] Improved tm-monitor formatting (#4023) * tm-monitor: tweaked formatting of start time and avg tx throughput. * tm-monitor: update health when validator number is updated. * Updated CHANGELOG_PENDING * Added PR number to CHANGELOG_PENDING. Improves `tm-monitor` formatting of start time (RFC1123 without unnecessary precision) and avg tx throughput (three decimal places). The old tx throughput display was confusing during local testing where the tx rate is low and displayed as 0. Also updates the monitor health whenever the validator number changes. It otherwise starts with moderate health and fails to update this once it discovers the validators, leading to incorrect health reporting and invalid uptime statistics. Let me know if you would like me to submit this as a separate PR. ### Before: ``` 2019-09-29 20:40:00.992834 +0200 CEST m=+0.024057059 up -92030989600.42% Height: 2518 Avg block time: 1275.496 ms Avg tx throughput: 0 per sec Avg block latency: 2.464 ms Active nodes: 4/4 (health: moderate) Validators: 4 NAME HEIGHT BLOCK LATENCY ONLINE VALIDATOR localhost:26657 2518 0.935 ms true true localhost:26660 2518 0.710 ms true true localhost:26662 2518 0.708 ms true true localhost:26664 2518 0.717 ms true true ``` ### After: ``` Sun, 29 Sep 2019 20:21:59 +0200 up 100.00% Height: 2480 Avg block time: 1361.445 ms Avg tx throughput: 0.735 per sec Avg block latency: 4.232 ms Active nodes: 4/4 (health: full) Validators: 4 NAME HEIGHT BLOCK LATENCY ONLINE VALIDATOR localhost:26657 2480 1.174 ms true true localhost:26660 2480 1.037 ms true true localhost:26662 2480 0.981 ms true true localhost:26664 2480 0.995 ms true true ``` --- CHANGELOG_PENDING.md | 5 +++++ tools/tm-monitor/monitor/network.go | 1 + tools/tm-monitor/ton.go | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 043c66c7e..eeafaf364 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -3,6 +3,7 @@ \*\* Special thanks to external contributors on this release: +@erikgrinaker Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermint). @@ -19,4 +20,8 @@ program](https://hackerone.com/tendermint). ### IMPROVEMENTS: +- [tools] [\#4023](https://github.com/tendermint/tendermint/issues/4023) Improved `tm-monitor` formatting of start time and avg tx throughput + ### BUG FIXES: + +- [tools] [\#4023](https://github.com/tendermint/tendermint/issues/4023) Refresh `tm-monitor` health when validator count is updated \ No newline at end of file diff --git a/tools/tm-monitor/monitor/network.go b/tools/tm-monitor/monitor/network.go index 45cf2ac3c..28cd52f2e 100644 --- a/tools/tm-monitor/monitor/network.go +++ b/tools/tm-monitor/monitor/network.go @@ -180,6 +180,7 @@ func (n *Network) UpdateNumValidatorsForHeight(num int, height int64) { if n.Height <= height { n.NumValidators = num } + n.updateHealth() } func (n *Network) GetHealthString() string { diff --git a/tools/tm-monitor/ton.go b/tools/tm-monitor/ton.go index cad17b39c..98d8d050c 100644 --- a/tools/tm-monitor/ton.go +++ b/tools/tm-monitor/ton.go @@ -61,11 +61,11 @@ func (o *Ton) Stop() { func (o *Ton) printHeader() { n := o.monitor.Network - fmt.Fprintf(o.Output, "%v up %.2f%%\n", n.StartTime(), n.Uptime()) + fmt.Fprintf(o.Output, "%v up %.2f%%\n", n.StartTime().Format(time.RFC1123Z), n.Uptime()) fmt.Println() fmt.Fprintf(o.Output, "Height: %d\n", n.Height) fmt.Fprintf(o.Output, "Avg block time: %.3f ms\n", n.AvgBlockTime) - fmt.Fprintf(o.Output, "Avg tx throughput: %.0f per sec\n", n.AvgTxThroughput) + fmt.Fprintf(o.Output, "Avg tx throughput: %.3f per sec\n", n.AvgTxThroughput) fmt.Fprintf(o.Output, "Avg block latency: %.3f ms\n", n.AvgBlockLatency) fmt.Fprintf(o.Output, "Active nodes: %d/%d (health: %s) Validators: %d\n", n.NumNodesMonitoredOnline, n.NumNodesMonitored, n.GetHealthString(), n.NumValidators) }