Skip to content

feat(tools): add linux-diag/ dispatcher for speedtest-cli, iperf3, mtr, traceroute - #13

Merged
David Mireles (louzt) merged 2 commits into
mainfrom
feat/linux-diag-tool
Jul 31, 2026
Merged

feat(tools): add linux-diag/ dispatcher for speedtest-cli, iperf3, mtr, traceroute#13
David Mireles (louzt) merged 2 commits into
mainfrom
feat/linux-diag-tool

Conversation

@louzt

@louzt louzt commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds tools/linux-diag/lzt-netdiag, a thin bash dispatcher over four network
diagnostic tools that are not packaged for Debian Forky upstream
(speedtest-cli, iperf3, mtr, traceroute). They run inside an Arch
Linux distrobox (arch-loust) and are exported back to host PATH via
distrobox-export --bin.

Why a dispatcher instead of calling the wrappers directly?

Concern Without dispatcher With dispatcher
Memory distrobox enter arch-loust -- speedtest-cli --simple lzt-netdiag st --simple
Tab-completion 4 distinct command names 1 canonical name with 6 subcommands
Auto-detection of local NICs Manual iw dev, ip route lzt-netdiag host
Tool availability Each wrapper is independent Pre-flight check fails fast with actionable error

Subcommands

Subcommand Pass-through to Notes
st speedtest-cli Accepts all native flags
i3 iperf3 Accepts all native flags
mtr mtr Accepts all native flags
trace traceroute Accepts all native flags
host host sysfs + iproute2 NIC auto-detect, default route, wireless quality, DNS, gateway ping
version all four binaries One-liner with versions + container name
-h, --help, help, no args Doc block extracted via sed

Why is this in NetBoozt?

The NetBoozt platform targets Windows users, but the build & maintain
workflow runs on Debian. When validating a release that claims "improved
connection-resilience on lossy networks", we need to reproduce typical
home-network pathologies — packet loss, MTU black holes, slow DNS,
asymmetric bandwidth — without polluting the host distro with Arch-only
packages. The dispatcher pattern lets the maintainer reproduce field issues
deterministically while keeping the host clean.

Files

Path LOC Role
tools/linux-diag/lzt-netdiag 164 bash dispatcher (mode 0755, set -euo pipefail)
tools/linux-diag/README.md 116 Setup, subcommand table, exit codes, rationale
.gitignore +1 exception !tools/linux-diag/

Verification

  • bash -n → SYNTAX OK
  • shellcheck → ALL CLEAN (SC2086 resolved via read -ra wl_arr)
  • lzt-netdiag --help → extracts doc block via sed, exit 0
  • lzt-netdiag host → prints NICs (wlp3s0 UP 192.168.1.67, enp2s0 DOWN, 6 docker bridges)
  • lzt-netdiag version → speedtest-cli 2.1.3 / iperf 3.21 / mtr 0.96 / traceroute 2.1.6
  • distrobox list confirms container arch-loust (Up 3 hours, docker.io/library/archlinux:latest)

Setup (one-time)

distrobox create -i archlinux:latest -n arch-loust
distrobox enter arch-loust -- sudo pacman -S speedtest-cli iperf3 mtr
distrobox enter arch-loust -- distrobox-export \
    --bin /usr/bin/speedtest-cli \
    --bin /usr/bin/iperf3 \
    --bin /usr/bin/mtr \
    --bin /usr/bin/traceroute \
    --export-path ~/.local/bin/
install -m 0755 tools/linux-diag/lzt-netdiag ~/.local/bin/lzt-netdiag

Out of scope

  • This PR does not include Tauri-side integration. The dispatcher is a
    CLI companion only. Wiring it into NetBoozt's Tauri UI (e.g. a new
    "diagnostics" tab) would be a separate PR and a separate discussion.
  • Does not modify NetBoozt release flow. NetBoozt binaries remain
    Windows-targeted (runs-on: windows-latest); this is for the maintainer's
    Debian build host only.

Summary by CodeRabbit

  • New Features

    • Added lzt-netdiag, a network diagnostics tool supporting speed tests, throughput testing, route analysis, and traceroute.
    • Added host diagnostics for local interfaces, routing, wireless status, DNS, gateway connectivity, and ping checks.
    • Added help and version commands, with clear errors for unsupported commands or missing prerequisites.
  • Documentation

    • Added setup, usage examples, exit codes, customization guidance, and details about the available diagnostic commands.

…r, traceroute

lzt-netdiag (164 LOC) is a thin bash dispatcher over the four
network diagnostic tools that are not packaged for Debian Forky
upstream. They run inside an Arch Linux distrobox (arch-loust) and
are exported back to host PATH via distrobox-export --bin.

Why a dispatcher instead of calling the wrappers directly:
  - One short command (lzt-netdiag st --simple) instead of writing
    'distrobox enter arch-loust -- speedtest-cli --simple' each time
  - Tab-completion target (single canonical name with subcommands)
  - Local-only affordances: 'host' (NIC auto-detect via sysfs +
    iproute2) and 'version' (one-liner of all 4 versions)

Subcommands: st | i3 | mtr | trace | host | version | --help.
Pre-flight: ensure_container_running + check_tool for all 4 binaries,
fail-fast with actionable error message.

.gitignore: tools/ is gitignored for one-off dev scripts. Add explicit
exception !tools/linux-diag/ so the dispatcher + README are committed.

Verified: bash -n OK, shellcheck clean (after read -ra for word-split
intent), lzt-netdiag --help extracts the doc block, lzt-netdiag host
prints NIC inventory including wireless wlp3s0 on this host.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@louzt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 89d63cfd-4d56-4f7e-9e04-7ce9e985606d

📥 Commits

Reviewing files that changed from the base of the PR and between fe87801 and 361ecad.

📒 Files selected for processing (2)
  • tools/linux-diag/README.md
  • tools/linux-diag/lzt-netdiag
📝 Walkthrough

Walkthrough

Adds the tracked lzt-netdiag Bash dispatcher, documentation, distrobox prerequisite validation, network-tool subcommands, host diagnostics, version reporting, and command error handling.

Changes

Linux network diagnostics

Layer / File(s) Summary
Tool packaging and usage contract
.gitignore, tools/linux-diag/README.md, tools/linux-diag/lzt-netdiag
Keeps tools/linux-diag/ tracked and documents the dispatcher’s setup, commands, arguments, exit codes, and customization.
Container and export validation
tools/linux-diag/lzt-netdiag
Adds strict Bash settings, configurable container selection, container-state checks, and exported-tool validation.
Command dispatch and reporting
tools/linux-diag/lzt-netdiag
Dispatches four network tools, adds host interface and connectivity diagnostics, reports versions, handles help, and rejects unknown commands.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant lzt-netdiag
  participant distrobox
  participant HostDiagnostics
  Operator->>lzt-netdiag: invoke subcommand
  lzt-netdiag->>distrobox: validate container and exported tools
  distrobox-->>lzt-netdiag: prerequisite status
  alt tool subcommand
    lzt-netdiag->>distrobox: run selected network tool
    distrobox-->>Operator: diagnostic output
  else host subcommand
    lzt-netdiag->>HostDiagnostics: inspect local network state
    HostDiagnostics-->>Operator: host diagnostic output
  end
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the new Linux diagnostics dispatcher and the tools it supports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/linux-diag-tool

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitignore:
- Line 61: Update the .gitignore rules for tools/linux-diag so the ignored
tools/ parent directory and its contents are explicitly re-included, allowing
lzt-netdiag and README.md to be tracked. Preserve the intended exclusion of
unrelated tools entries, and verify both files with git check-ignore -v.

In `@tools/linux-diag/lzt-netdiag`:
- Around line 57-60: Align the missing-tool exit status across the diagnostic
script and documentation: update die() in tools/linux-diag/lzt-netdiag (57-60)
to use the selected status, make check_tool() in tools/linux-diag/lzt-netdiag
(84-88) consistently return that status, and document the same status in
tools/linux-diag/README.md (82-89).
- Around line 142-145: Update the gateway reachability block in lzt-netdiag to
detect whether the host-side ping command is available, report it as unavailable
when missing, and continue the diagnostic without aborting; otherwise preserve
the existing unreachable/reachability output. In tools/linux-diag/README.md
lines 101-106, document the required host package or explicitly state the
supported ping prerequisite.
- Around line 18-26: Ensure the canonical setup instructions install or verify
the package providing /usr/bin/traceroute before exporting it in
tools/linux-diag/lzt-netdiag lines 18-26, then mirror the same guaranteed setup
step in tools/linux-diag/README.md lines 33-45 so both documented setup surfaces
are consistent.
- Around line 90-94: Scope the preflight block in tools/linux-diag/lzt-netdiag
around ensure_container_running and check_tool so help and host dispatch without
container or tool checks, while commands requiring those dependencies retain the
appropriate checks. Preserve the local-only/help contract documented in
tools/linux-diag/README.md lines 26-28; no direct README change is needed unless
the implementation requires documentation alignment.
- Around line 71-81: Update ensure_container_running to filter distrobox list
output for ${CONTAINER_NAME} before evaluating its status, removing the global
“any container is Up” shortcut. Explicitly fail when the requested container is
missing, and require its row to report Up while handling supported distrobox
list output formats without relying on a fixed positional field.
- Around line 122-130: Update the wireless-interface parsing in the wl_list
handling block to use mapfile -t or readarray, preserving every
newline-separated interface from the subshell. Keep the existing printf output
and wireless-directory detection unchanged.

In `@tools/linux-diag/README.md`:
- Around line 47-48: Update the installation instructions near the lzt-netdiag
install command to create ~/.local/bin before installing, using either mkdir -p
or install’s directory-creation option, while preserving the existing 0755
permissions and destination.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 635af002-e711-43d6-a48d-0c4a9b8650ee

📥 Commits

Reviewing files that changed from the base of the PR and between 43accb8 and fe87801.

📒 Files selected for processing (3)
  • .gitignore
  • tools/linux-diag/README.md
  • tools/linux-diag/lzt-netdiag

Comment thread .gitignore

# Development tools (NOT for end users - gitignored)
tools/ # Dev scripts (screenshot gen, favicon gen, etc.)
!tools/linux-diag/ # Linux network diagnostics dispatcher (lzt-netdiag) - COMMITTED

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Re-include the parent directory and its contents.

Because tools/ is ignored, the negation for tools/linux-diag/ does not make tools/linux-diag/lzt-netdiag or README.md trackable. Use parent/content exception rules, for example:

+!tools/
+tools/*
 !tools/linux-diag/
+!tools/linux-diag/**

Verify with git check-ignore -v tools/linux-diag/lzt-netdiag tools/linux-diag/README.md.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
!tools/linux-diag/ # Linux network diagnostics dispatcher (lzt-netdiag) - COMMITTED
!tools/
tools/*
!tools/linux-diag/
!tools/linux-diag/**
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.gitignore at line 61, Update the .gitignore rules for tools/linux-diag so
the ignored tools/ parent directory and its contents are explicitly re-included,
allowing lzt-netdiag and README.md to be tracked. Preserve the intended
exclusion of unrelated tools entries, and verify both files with git
check-ignore -v.

Comment thread tools/linux-diag/lzt-netdiag
Comment on lines +57 to +60
die() {
echo "lzt-netdiag: $*" >&2
exit 1
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Align the missing-tool exit-code contract.

  • tools/linux-diag/lzt-netdiag#L57-L60: return 127 for missing exported tools, or change the documented status.
  • tools/linux-diag/lzt-netdiag#L84-L88: make check_tool() use the selected status consistently.
  • tools/linux-diag/README.md#L82-L89: document the same status exposed by the script.
📍 Affects 2 files
  • tools/linux-diag/lzt-netdiag#L57-L60 (this comment)
  • tools/linux-diag/lzt-netdiag#L84-L88
  • tools/linux-diag/README.md#L82-L89
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/linux-diag/lzt-netdiag` around lines 57 - 60, Align the missing-tool
exit status across the diagnostic script and documentation: update die() in
tools/linux-diag/lzt-netdiag (57-60) to use the selected status, make
check_tool() in tools/linux-diag/lzt-netdiag (84-88) consistently return that
status, and document the same status in tools/linux-diag/README.md (82-89).

Comment thread tools/linux-diag/lzt-netdiag
Comment thread tools/linux-diag/lzt-netdiag Outdated
Comment thread tools/linux-diag/lzt-netdiag
Comment thread tools/linux-diag/lzt-netdiag Outdated
Comment on lines +142 to +145
printf "\n=== Gateway reachability (5 pings) ===\n"
gw="$(ip route show default 2>/dev/null | awk '/default/ {print $3; exit}')"
if [ -n "$gw" ]; then
ping -c 5 -W 2 "$gw" 2>&1 | tail -4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Declare and handle the host-side ping dependency.

  • tools/linux-diag/lzt-netdiag#L142-L145: check ping and report unavailable/unreachable without aborting the diagnostic.
  • tools/linux-diag/README.md#L101-L106: list the required host package or explicitly document the supported prerequisite.
📍 Affects 2 files
  • tools/linux-diag/lzt-netdiag#L142-L145 (this comment)
  • tools/linux-diag/README.md#L101-L106
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/linux-diag/lzt-netdiag` around lines 142 - 145, Update the gateway
reachability block in lzt-netdiag to detect whether the host-side ping command
is available, report it as unavailable when missing, and continue the diagnostic
without aborting; otherwise preserve the existing unreachable/reachability
output. In tools/linux-diag/README.md lines 101-106, document the required host
package or explicitly state the supported ping prerequisite.

Comment on lines +47 to +48
# 3. Drop this directory on the host
install -m 0755 lzt-netdiag ~/.local/bin/lzt-netdiag

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Create the install destination first.

install -m does not create ~/.local/bin; setup fails on hosts where that directory is absent. Add mkdir -p ~/.local/bin or use install -Dm0755.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/linux-diag/README.md` around lines 47 - 48, Update the installation
instructions near the lzt-netdiag install command to create ~/.local/bin before
installing, using either mkdir -p or install’s directory-creation option, while
preserving the existing 0755 permissions and destination.

- Scope preflight (ensure_container_running + check_tool) to only the
  four network-tool subcommands (st, i3, mtr, trace). 'help', 'host',
  and 'version' no longer require the distrobox exports; 'host' is
  purely local sysfs/iproute2.

- ensure_container_running: filter distrobox list output by
  CONTAINER_NAME first, then check its Up status. The previous
  awk-based 'any container is Up' shortcut silently passed when
  another distrobox was running but ours was not.

- Use mapfile -t for wireless interfaces (was read -ra <<< which
  only consumes the first line of the subshell output).

- Add die_missing_tool with exit 127 to match the documented exit
  code for missing host exports; die() with exit 1 is reserved for
  argument/container errors.

- 'host' gateway reachability: guard the ping command with
  command -v; previously a missing iputils-ping would have aborted
  the whole 'host' run under set -e.

- Setup instructions: add 'traceroute' to pacman -S in both the
  script header and README so the export block doesn't 404.

Verified: bash -n, shellcheck clean, host subcommand still prints
wlp3s0 + gateway pings, version reports all 4 versions + container,
--help extracts doc block, unknown subcommand still exits 1.
@louzt
David Mireles (louzt) merged commit 21be0c9 into main Jul 31, 2026
3 checks passed
@louzt
David Mireles (louzt) deleted the feat/linux-diag-tool branch July 31, 2026 02:14
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