feat: outage measurement, TUI path trace, and history sparkline - #59
Merged
Merged
Conversation
servak
force-pushed
the
feature/outage-mtr-history
branch
from
September 23, 2026 08:41
901f432 to
d792af3
Compare
- Record an outage when 3 or more consecutive probes are lost, with its start, end, duration and lost probe count. It starts at the first lost probe and ends at the next success; shorter runs are ordinary loss. - Buffer results for timeout + interval and apply them in send order, so a timeout reported after a later success does not split an outage. The buffer is flushed when the event channel closes. - Return deep-copied snapshots from SortBy/GetMetrics so the UI no longer reads live metrics without the lock. - Add RTT percentiles (nearest rank over the history). - Use a strict ordering for descending sorts so equal rows keep their order across refreshes. - Replace SetBeepEnabled with Options.DisableBeep for batch runs.
- Host details show RTT p50/p95/p99 and the recent outages with their total and longest downtime. - Table reports end with a cross-target outage timeline; json/csv gain outages[], outage_count, total_downtime_ms, longest_outage_ms and the RTT percentiles. - FormatLastFailCell adds the related outage duration to the last failure time (red while down, yellow after recovery). - FormatSparkline draws recent probes with bar height by how many ms an RTT exceeds the median, so normal jitter stays flat.
- Insert a History sparkline column after Loss and show the outage duration in the LastFailTime cell. - Record the selected host on every selection change and restore it by name, so re-sorting keeps the same host selected. A filter that hides it shows the first row meanwhile without losing the selection. - Refresh the detail panel from the latest snapshot on every update.
Each round sends ICMP echo requests with TTL 1..30 and keeps per-hop loss and RTT statistics. Replies are matched by echo ID/seq, including the datagram quoted in Time Exceeded / Destination Unreachable messages (IPv4 with IHL options, IPv6). A raw socket is preferred, with a fallback to unprivileged datagram ICMP, which still receives Time Exceeded on macOS. Hop addresses are reverse-resolved in the background. Network integration tests run with -tags integration.
Press p to show an MTR-style trace next to the host list. It follows the selection and traces the host part of any target (tcp://, https://, dns://, ...). The trace starts off the UI goroutine and runs at most one round per second so router ICMP rate limiting does not show up as loss. Hops still waiting for a reply show 'waiting', and loss only at intermediate hops is marked as likely rate limiting.
servak
force-pushed
the
feature/outage-mtr-history
branch
from
September 23, 2026 22:05
8963f2a to
ef2f0f5
Compare
Each round sent TTL 1..30 back to back, and kept doing so when the destination did not answer. Home routers took the burst for an ICMP flood and dropped ICMP for every host behind them for a while, so opening the path view on one machine made mping fail on the others. - Spread a round's probes evenly over the interval, like mtr. - While the destination is unknown, probe at most 8 TTLs past the farthest hop that has replied instead of up to 30.
servak
force-pushed
the
feature/outage-mtr-history
branch
from
September 24, 2026 04:35
a652c70 to
e5346bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1. Outage measurement (for failover / maintenance tests)
timeout + intervaland applied in send-time order. The buffer is flushed when the event channel closes, so final reports are complete.16:44:20 (DOWN 5.20s)in red while down and16:44:15 (0.50s)in yellow after recovery.batchtable output.outages[],outage_count,total_downtime_ms,longest_outage_ms.2. MTR-style path trace in the TUI
internal/tracepackage. Each round it sends ICMP echo with TTL 1..30 and matches replies by echo ID/seq, including the datagram quoted in Time Exceeded / Dest Unreachable messages (handles IPv4 IHL options and IPv6).ptoggles a live path panel that follows the selected host. Any target type works: fortcp://,https://,dns://, … the host part is traced.waiting. The panel also notes when loss appears only at intermediate hops, which is usually ICMP rate limiting rather than real loss.mping mtrsubcommand; the trace is only available in the TUI.3. History column and percentiles
×marks a failure. Bar height is how many milliseconds an RTT exceeds the host's median (+5/10/20/50/100/200/500ms). A host's normal jitter therefore stays flat, and +100ms or more is drawn in the warning color.Fixes
SortBy/GetMetricsreturned live pointers that the UI read without the lock. They now return deep-copied snapshots, and panels are refreshed from the latest snapshot on every update.Cleanup
stats.Options.DisableBeep. This replacesSetBeepEnabled, which was added in feat(batch): add json/csv output, max-loss exit code, and RTT jitter #58.NewMetricsManagerWithHistorySizeis removed; useNewMetricsManagerWithOptions.Test plan
go test -race ./...,golangci-lint run(0 issues)-tags integration)batch→ 1.600s outage = 8 lost × 200ms🤖 Generated with Claude Code