Skip to content

Feature/mtr monitor#25

Merged
nagayon-935 merged 9 commits into
mainfrom
feature/mtr-monitor
May 31, 2026
Merged

Feature/mtr monitor#25
nagayon-935 merged 9 commits into
mainfrom
feature/mtr-monitor

Conversation

@nagayon-935

Copy link
Copy Markdown
Owner

No description provided.

- Add HopStats, MTRStats, HopView types in internal/stats/mtr.go
  with EnsureLen/RecordReply/RecordLoss/SetIP/View/Reset methods
- Add MTR() lazy accessor on TargetStats, mtrStats field
- Include MTRHops []HopView in TargetStats.GetView() snapshot
- Reset() now clears mtrStats
- Add HopSummary to export.go and populate in BuildSnapshot
- Table-driven unit tests with race detector coverage
…elpers

- Add RegisterTraceChan/UnregisterTraceChan methods to Pinger, used by both
  TraceRoute and the new MTR engine (eliminates inline append/remove in traceroute.go)
- Add OpenHopSocket: opens a persistent send socket + registers one traceChan
  for the full MTR loop lifetime (more efficient than per-call registration)
- Add ProbeHop: single TTL-limited probe with traceChan or socket-fallback receive
- Add acceptHopPacket: shared accept logic factored from TraceRoute
- Add NextTraceID, GetASNFor exported accessors needed by the MTR engine
- Define hopSendConnV4/hopSendConnV6 interfaces for testability
- Refactor TraceRoute to use RegisterTraceChan/UnregisterTraceChan (no behaviour change)
- Unit tests: accept/reject matching, traceChan receive, timeout, ctx cancel, unique IDs
- New package internal/mtr with Engine, HopProber interface, Config
- One goroutine per target: discovery phase (sequential TTL probing) then
  continuous probe loop (one probe per hop per interval)
- Periodic re-discovery via RediscoverEvery ticker for route changes
- EnsureLen grows MTRStats gracefully; star hops accumulate loss at 100%
- Config defaults: 30 hops, 1s interval, 1s hop timeout, 10m rediscover
- Table-driven tests: clean path, star hop, loss accumulation,
  ctx cancel stops goroutines, multiple targets concurrently
…un loop

- Add -M/--mtr CLI flag and mtr YAML key
- Add pingerMTRAdapter satisfying mtr.HopProber interface (type-asserts
  mtr.HopSocket back to *pinger.HopSocket for ProbeHop dispatch)
- Wire mtrEngine into startPinger/stopPinger/stopAll/resetMTR
- Add MTREnabled, OnResetMTR to ui.RunOptions (TUI pane wired in Phase 5)
- MTR stats now populate and appear in -j JSON export when -M is active
- Add internal/ui/mtr_view.go: renderMTRTable with mtr-standard columns
  (Hop, Host/ASN, Loss%, Snt, Recv, Last, Avg, Min, Max, Jitter)
  Color thresholds reuse lossColorForRate from tui_helpers.go
  Compact mode drops Min/Max/Jitter columns on narrow terminals
  Star (*) hops display with 100% loss and dashes for latency
- Add MTR Monitor pane to tui.go (double-border, black background)
- Replace combinatorial if-else layout with dynamic flex builder:
  append enabled panes (trace/mtr/port) with weight 3 (alone) or 2 (multiple)
- Extend Tab focus cycle to include MTR pane; generalised loop-based
  cycle replaces the hard-coded trace/port specific cases
- Wire renderMTRTable into the updateTable refresh loop
- 'R' reset key triggers onResetMTR callback when MTR is enabled
…g pane style

- Redesign mtr_view.go to use box-drawing characters (┌─┬─┐ │ └─┴─┘)
  matching the Port Monitor and Traceroute pane style
- Fix '...' truncation: mtrHopColW increased to 5 (was 4) so '  1. '
  fits without overflow; paddedCell used instead of rightPaddedCell
- Add mtrLossColorTag/mtrRTTColorTag returning tview color tag strings
  (e.g. '[green]', '[orange]', '[red::b]') instead of tcell.Color.String()
- Target label displayed in a full-width header row inside the table border
- Full mode: Hop | Host | Loss% | Snt | Recv | Last | Avg | Min | Max | Jitter
- Compact mode (narrow terminal): Hop | Host | Loss% | Snt | Last | Avg
- 'Discovering...' shown when hops not yet available
- Add mtr_view_test.go: border structure, star hop, compact/full columns,
  multi-target, hop number never truncated (TTL 1-30)
…duced by ├─┬─┤

Before: ┌─┬─┬...┐ top border had column dividers, then label row had no
internal separators, causing visual inconsistency (dividers appear
out of nowhere).

After:
  ┌──────────────────────────────────────────┐  ← full-width, no ┬
  │ 8.8.8.8 (8.8.8.8)                       │  ← label, left/right only
  ├─────┬──────────────────┬────────┬...─────┤  ← ┬ introduces columns
  │ Hop │ Host             │ Loss%  │ ...    │
  ├─────┼──────────────────┼────────┼...─────┤
  │  1. │ 192.168.1.1      │  0.0%  │ ...    │
  └─────┴──────────────────┴────────┴...─────┘
Replace bare destination label with 'SrcIP -> DstIP' format using the
existing displaySourceIPForDst helper (respects IPv4/IPv6 and 'Auto').

- IP target:       '192.168.1.5 -> 8.8.8.8'
- Hostname target: 'example.com (192.168.1.5 -> 93.184.216.34)'
- Add MTR Monitor pane to Features list (both EN/JA)
- Add -M usage examples and -T -M simultaneous usage
- Add -M / --mtr and -j / --json-output to Options table
- Add mtr: true and json-output keys to hosts.yaml example
- Update Tab key description to include MTR Monitor in cycle
- Add dedicated 'MTR Monitor pane' section documenting all columns,
  compact mode, SrcIP->DstIP header, and JSON export integration
- Fix duplicate license entry in README.ja.md
@nagayon-935 nagayon-935 merged commit e794b45 into main May 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant