Skip to content

[RFC] Armbianmonitor refactor#9327

Open
EvilOlaf wants to merge 11 commits into
armbian:mainfrom
EvilOlaf:armbianmonitor-refactor
Open

[RFC] Armbianmonitor refactor#9327
EvilOlaf wants to merge 11 commits into
armbian:mainfrom
EvilOlaf:armbianmonitor-refactor

Conversation

@EvilOlaf
Copy link
Copy Markdown
Member

@EvilOlaf EvilOlaf commented Feb 1, 2026

Description

  • split log upload into dedicated tool

    • adjust its logic to auto upload but allow user to output to stdout by simple key press
    • leave -u/-U in armbianmonitor intact but add deprecation notice
  • armbianmonitor

    • remove tons of dead code
    • remove old benchmark tools
    • remove rpimonitor and dirty binary patch hack
    • remove references to EOL userspaces and 3.y kernel from middle-age
      • perhaps add references to sbcbench later for proper results
    • remove old debug mode
      • was referencing to ix.io which has been dead for years and nobody ever complained
    • various fixes

@rpardini you may wanna have a look at this...or not :D

How Has This Been Tested?

  • only armbian-debug has been tested so far

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Added a dedicated debug utility to collect extensive system diagnostics, support multiple upload endpoints, offer a 5s interactive countdown to switch to stdout (line-numbered), sanitize sensitive-looking data, and provide clear upload success/failure messaging.
  • Refactor

    • Simplified the existing monitor tool by removing legacy upload flows and deprecating upload flags; help text and options now redirect users to the new debug utility.

@EvilOlaf EvilOlaf requested a review from a team as a code owner February 1, 2026 13:15
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

Adds a new armbian-debug utility to collect, sanitize, and upload comprehensive Armbian diagnostic data (with interactive stdout fallback) and removes/deprecates upload-related collector functionality from armbianmonitor, redirecting support-info upload flows to armbian-debug.

Changes

Cohort / File(s) Summary
New debug utility
packages/bsp/common/usr/bin/armbian-debug
Adds a new Bash script exposing Main() and CollectSupportInfo() that aggregates extensive diagnostics, sanitizes IP-like data, attempts uploads to multiple paste servers via curl (observes PIPESTATUS), offers a 5s interactive prompt to force stdout, and falls back to numbered, redacted stdout on failure.
armbianmonitor cleanup
packages/bsp/common/usr/bin/armbianmonitor
Removes legacy upload/collector functions (InstallRPiMonitor, PatchRPiMonitor_for_sun8i, CollectSupportInfo, Run7ZipBenchmark, PreRequisits); deprecates -u/-U upload options and redirects that flow to armbian-debug; shortens ParseOptions() getopts from 'hHuUrRmMsnNd:Dc:C:pPvz' to 'hHuUrRmMsnNd:c:C:pPv' and updates usage/help text.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User as User
    participant Script as armbian-debug
    participant Shell as ShellCmds
    participant Curl as curl
    participant Paste as PasteServer

    User->>Script: run armbian-debug (interactive)
    Script->>User: 5s prompt to switch to stdout
    Script->>Shell: CollectSupportInfo() (dmesg, hw, lshw, iostat, etc.)
    Shell-->>Script: diagnostic payload
    Script->>Script: sanitize payload (redact IPs)
    Script->>Curl: upload to PasteServer A
    Curl-->>Script: exit status (PIPESTATUS)
    alt upload success
        Paste-->>Script: URL
        Script->>User: success message with URL
    else upload failure
        Script->>Curl: try next PasteServer...
        alt all attempts fail
            Script->>User: fallback -> print numbered, redacted stdout
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

"I nibbled logs beneath the moon,
I hopped through dmesg and sysfs tune.
If paste won't hold my debug song,
I'll print the lines and hum along. 🐇"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title '[RFC] Armbianmonitor refactor' is vague and generic, using 'refactor' without specifying the main functional change—introducing armbian-debug as a dedicated tool and deprecating upload features in armbianmonitor. Consider a more specific title such as '[RFC] Split debug upload into dedicated armbian-debug tool' or '[RFC] Refactor armbianmonitor: move debug uploads to new armbian-debug' to clearly communicate the primary change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added 02 Milestone: First quarter release size/large PR with 250 lines or more Needs review Seeking for review BSP Board Support Packages labels Feb 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/bsp/common/usr/bin/armbian-debug`:
- Around line 57-106: The curl call inside the paste_server upload loop can hang
indefinitely; update the curl invocation in the for paste_server loop (the
pipeline that ends with curl -s --fail --data-binary `@-`
"https://${paste_server}/log") to include connection and overall timeouts (e.g.
--connect-timeout 10 and --max-time 30) so stalled servers fail fast and allow
the script to fall back to stdout; keep the rest of the pipeline and PIPESTATUS
handling unchanged.

Comment thread packages/bsp/common/usr/bin/armbian-debug Outdated
@EvilOlaf
Copy link
Copy Markdown
Member Author

EvilOlaf commented Feb 3, 2026

I have no idea where this conflict comes from and how I produced that but nevertheless this is more POC and RFC, so....

@igorpecovnik igorpecovnik added 05 Milestone: Second quarter release and removed 02 Milestone: First quarter release labels Feb 3, 2026
@rpardini
Copy link
Copy Markdown
Member

rpardini commented Feb 4, 2026

I have very strict orders from my psychiatrist to never look at this again 😉 that said I fully trust you on this

@EvilOlaf
Copy link
Copy Markdown
Member Author

EvilOlaf commented Feb 4, 2026

Haha.
Well fair warning: I did not touch the internals as they work...much. Most is cleanup and remove old stuff and split functionality.

@igorpecovnik
Copy link
Copy Markdown
Member

What is the status here?

@EvilOlaf
Copy link
Copy Markdown
Member Author

Waiting for review :)
There is no urgency here, this can be shifted after release to allow more careful review and testing.

@igorpecovnik
Copy link
Copy Markdown
Member

@EvilOlaf
Copy link
Copy Markdown
Member Author

Ah. Yes, I did not do any tests yet since it was more like a request for feedback if I went too far or not far enough.

@github-actions github-actions Bot added the 02 Milestone: First quarter release label Feb 17, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bsp/common/usr/bin/armbianmonitor (1)

128-128: ⚠️ Potential issue | 🟡 Minor

Typo: "referance" → "reference".

-	# Kept for referance.
+	# Kept for reference.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbianmonitor` at line 128, Fix the typo in the
retained comment: change the string "# Kept for referance." to "# Kept for
reference." in the armbianmonitor script (locate the comment line containing
"Kept for referance."). Ensure only the spelling is corrected and no other text
or behavior is modified.
🧹 Nitpick comments (2)
packages/bsp/common/usr/bin/armbianmonitor (2)

718-719: Subshell () means route may still be missing after install failure.

The (apt-get update && apt-get -f -y install net-tools) runs in a subshell. If installation fails, the script continues and route calls on line 722+ will fail. Consider using { ...; } or adding a post-check. That said, this pattern is used elsewhere in the file (lines 518-525), so it's consistent with existing style.

Suggested improvement
-	which route > /dev/null 2>&1 || (apt-get update && apt-get -f -y install net-tools)
+	if ! command -v route > /dev/null 2>&1; then
+		apt-get update && apt-get -f -y install net-tools
+		command -v route > /dev/null 2>&1 || { echo "Error: 'route' command not available. Install net-tools." >&2; exit 1; }
+	fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbianmonitor` around lines 718 - 719, The check
that ensures net-tools is installed uses a subshell for the install step so a
failed install won't stop the main shell and subsequent `which route` usage may
still fail; change the construct that follows `which route` (the `(apt-get
update && apt-get -f -y install net-tools)` invocation) to run in the current
shell (e.g., use a brace group or sequential commands) and/or add an explicit
post-install verification of `route` success, ensuring the `apt-get` failure
propagates or the script exits if `route` is still missing; locate the `which
route` check and the net-tools install call to apply this fix.

58-58: Remove unused r, R, p, P flags from getopts string.

These options are present in the getopts string but have no corresponding case handlers, so they fall through to the default * case and print "Invalid flag". Since they're unused dead code, remove them to match the active handlers.

-	while getopts 'hHuUrRmMsnNd:c:C:pPv' c; do
+	while getopts 'hHuUmMsnNd:c:C:v' c; do
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbianmonitor` at line 58, The getopts option
string in the while loop (the "while getopts 'hHuUrRmMsnNd:c:C:pPv' c; do" line)
contains unused flags r, R, p, and P; remove those characters from the quoted
option string so it only lists the active flags handled in the case block (e.g.,
change the string to omit rR pP while keeping the other options and any
arguments like : where needed), ensuring the getopts invocation and its variable
c remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bsp/common/usr/bin/armbianmonitor`:
- Around line 83-100: The "Launching armbian-debug now..." message is printed
before verifying the tool exists in the u|U option handler; move the message so
it is only printed after a successful existence check. Modify the u|U case
around the checks of /usr/bin/armbian-debug and "$(dirname "$0")/armbian-debug"
(the exec branches) so you perform the -x existence tests first, then print
"Launching armbian-debug now..." right before calling exec, and leave the
existing error echo/exit path unchanged if neither path is found.

---

Outside diff comments:
In `@packages/bsp/common/usr/bin/armbianmonitor`:
- Line 128: Fix the typo in the retained comment: change the string "# Kept for
referance." to "# Kept for reference." in the armbianmonitor script (locate the
comment line containing "Kept for referance."). Ensure only the spelling is
corrected and no other text or behavior is modified.

---

Nitpick comments:
In `@packages/bsp/common/usr/bin/armbianmonitor`:
- Around line 718-719: The check that ensures net-tools is installed uses a
subshell for the install step so a failed install won't stop the main shell and
subsequent `which route` usage may still fail; change the construct that follows
`which route` (the `(apt-get update && apt-get -f -y install net-tools)`
invocation) to run in the current shell (e.g., use a brace group or sequential
commands) and/or add an explicit post-install verification of `route` success,
ensuring the `apt-get` failure propagates or the script exits if `route` is
still missing; locate the `which route` check and the net-tools install call to
apply this fix.
- Line 58: The getopts option string in the while loop (the "while getopts
'hHuUrRmMsnNd:c:C:pPv' c; do" line) contains unused flags r, R, p, and P; remove
those characters from the quoted option string so it only lists the active flags
handled in the case block (e.g., change the string to omit rR pP while keeping
the other options and any arguments like : where needed), ensuring the getopts
invocation and its variable c remain unchanged.

Comment thread packages/bsp/common/usr/bin/armbianmonitor
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (5)
packages/bsp/common/usr/bin/armbian-debug (4)

28-37: Auto-installing curl via apt-get without apt-get update may fail on a stale cache.

If the package lists are stale or missing, apt-get -f -y install curl could fail. Consider running apt-get update first, or at minimum warn the user that installation failed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbian-debug` around lines 28 - 37, The script's
curl-install branch (the if checking "command -v curl") runs apt-get -f -y
install curl which can fail on stale package lists; modify that branch to run
apt-get update first (or run apt-get update && apt-get -f -y install curl), and
on non-root or if install fails print a clear error advising the user to run
apt-get update and retry (or manually install curl). Ensure you update the block
that contains the command -v curl check and the apt-get -f -y install curl
invocation to include the update and a failure message.

109-119: which is deprecated; use command -v consistently.

Line 115 uses which lshw while elsewhere in this file (line 29) you correctly use command -v. which is not POSIX and may not be available on minimal installs.

Proposed fix
-	which lshw > /dev/null 2>&1 && (
+	command -v lshw > /dev/null 2>&1 && (
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbian-debug` around lines 109 - 119, In
CollectSupportInfo() replace the non-POSIX check using "which lshw" with a
POSIX-safe "command -v lshw" check to match the rest of the script; update the
conditional that currently reads which lshw > /dev/null 2>&1 to use command -v
lshw > /dev/null 2>&1 so the lshw block executes only when lshw is present and
avoids relying on which.

130-133: nvme with no arguments may not exit 0 on all versions.

Running nvme with no subcommand to check availability is fragile — some versions print help and exit 0, others may exit non-zero. Using command -v nvme would be a more reliable existence check, consistent with the curl check above.

Proposed fix
-	nvme > /dev/null 2>&1 && (
+	command -v nvme > /dev/null 2>&1 && (
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbian-debug` around lines 130 - 133, The
availability check currently runs the binary itself with "nvme > /dev/null 2>&1
&& (...)" which is fragile; replace that check with a path lookup via "command
-v nvme >/dev/null 2>&1 && (...)" so the script reliably detects presence of the
nvme executable before running "nvme list" (update the conditional that
surrounds the echo and nvme list invocation).

120-125: Same pattern: use command -v instead of bare command invocation for lsusb and lspci.

Lines 120 and 126 run lsusb/lspci with no args just to check existence. Prefer command -v for consistency and reliability.

Proposed fix
-	lsusb > /dev/null 2>&1 && (
+	command -v lsusb > /dev/null 2>&1 && (
...
-	lspci > /dev/null 2>&1 && (
+	command -v lspci > /dev/null 2>&1 && (
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbian-debug` around lines 120 - 125, Replace
the bare command existence checks that use `lsusb > /dev/null 2>&1 && (...)` and
`lspci > /dev/null 2>&1 && (...)` with POSIX-safe checks using `command -v lsusb
>/dev/null 2>&1 && (...)` and `command -v lspci >/dev/null 2>&1 && (...)`; keep
the inner blocks (the `echo` calls, `lsusb ${VERBOSE}`, `lsusb -t`, and the
corresponding `lspci` usage) unchanged so the script verifies availability via
`command -v` before invoking `lsusb`/`lspci`.
packages/bsp/common/usr/bin/armbianmonitor (1)

718-719: Subshell swallows installation failure for net-tools.

The (apt-get update && apt-get ... install net-tools) runs in a subshell due to (...). If installation fails, the script continues silently and route will fail on line 722 with a confusing error. Consider using { ...; } instead, or adding an explicit check after install.

Proposed fix
-	which route > /dev/null 2>&1 || (apt-get update && apt-get -f -y install net-tools)
+	if ! command -v route > /dev/null 2>&1; then
+		apt-get update && apt-get -f -y install net-tools || { echo "'route' command not found and installation failed." >&2; exit 1; }
+	fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bsp/common/usr/bin/armbianmonitor` around lines 718 - 719, The
current check "which route > /dev/null 2>&1 || (apt-get update && apt-get -f -y
install net-tools)" uses a subshell so failures are swallowed; replace the
subshell usage with a compound command or explicit post-install check: run
apt-get update and apt-get -f -y install net-tools in the current shell (use {
...; } or sequential commands) and then verify the install by re-checking "which
route" (or testing exit status) and aborting or logging an error if the install
failed; update the block that contains the "which route" check and the install
invocation accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bsp/common/usr/bin/armbian-debug`:
- Line 73: The dmesg invocation uses the --color=always flag which embeds ANSI
escape sequences into uploaded paste data; update the dmesg call (the line
invoking dmesg) to use --color=never or remove the color flag entirely so output
has no ANSI escapes and won’t pollute paste uploads or interfere with IP
sanitization.
- Around line 56-106: The upload path and both stdout/fallback paths collect
different info and re-run CollectSupportInfo which can produce inconsistent
results; change the flow to collect the full payload once into a temp file
(capture LC_ALL=C date, dmesg --color=always, and CollectSupportInfo into a temp
file), then use that temp file for the curl upload loop (while still applying
the IP-scrubbing sed) and for any stdout/fallback printing (apply awk/nl same as
current). Update logic around paste_servers, upload_success, and PIPESTATUS to
read from the temp file instead of re-invoking CollectSupportInfo, and ensure
the temp file is cleaned up at the end.

---

Nitpick comments:
In `@packages/bsp/common/usr/bin/armbian-debug`:
- Around line 28-37: The script's curl-install branch (the if checking "command
-v curl") runs apt-get -f -y install curl which can fail on stale package lists;
modify that branch to run apt-get update first (or run apt-get update && apt-get
-f -y install curl), and on non-root or if install fails print a clear error
advising the user to run apt-get update and retry (or manually install curl).
Ensure you update the block that contains the command -v curl check and the
apt-get -f -y install curl invocation to include the update and a failure
message.
- Around line 109-119: In CollectSupportInfo() replace the non-POSIX check using
"which lshw" with a POSIX-safe "command -v lshw" check to match the rest of the
script; update the conditional that currently reads which lshw > /dev/null 2>&1
to use command -v lshw > /dev/null 2>&1 so the lshw block executes only when
lshw is present and avoids relying on which.
- Around line 130-133: The availability check currently runs the binary itself
with "nvme > /dev/null 2>&1 && (...)" which is fragile; replace that check with
a path lookup via "command -v nvme >/dev/null 2>&1 && (...)" so the script
reliably detects presence of the nvme executable before running "nvme list"
(update the conditional that surrounds the echo and nvme list invocation).
- Around line 120-125: Replace the bare command existence checks that use `lsusb
> /dev/null 2>&1 && (...)` and `lspci > /dev/null 2>&1 && (...)` with POSIX-safe
checks using `command -v lsusb >/dev/null 2>&1 && (...)` and `command -v lspci
>/dev/null 2>&1 && (...)`; keep the inner blocks (the `echo` calls, `lsusb
${VERBOSE}`, `lsusb -t`, and the corresponding `lspci` usage) unchanged so the
script verifies availability via `command -v` before invoking `lsusb`/`lspci`.

In `@packages/bsp/common/usr/bin/armbianmonitor`:
- Around line 718-719: The current check "which route > /dev/null 2>&1 ||
(apt-get update && apt-get -f -y install net-tools)" uses a subshell so failures
are swallowed; replace the subshell usage with a compound command or explicit
post-install check: run apt-get update and apt-get -f -y install net-tools in
the current shell (use { ...; } or sequential commands) and then verify the
install by re-checking "which route" (or testing exit status) and aborting or
logging an error if the install failed; update the block that contains the
"which route" check and the install invocation accordingly.

Comment thread packages/bsp/common/usr/bin/armbian-debug Outdated
Comment thread packages/bsp/common/usr/bin/armbian-debug Outdated
@igorpecovnik
Copy link
Copy Markdown
Member

Is it near completion?

@EvilOlaf
Copy link
Copy Markdown
Member Author

EvilOlaf commented Mar 1, 2026

Perhaps I can throw some nitpicks at llm to fix them but besides that I think so.

EvilOlaf and others added 9 commits May 8, 2026 05:06
Perhaps add a reference to sbcbench later for proper benchmarking
-D was referencing to ix.io which has been dead for years now and nobody complained
7z benchmark was interesting years ago when sbcs weren't as powerful as they are today. Perhaps also here reference to sbcbench for proper results.
well...actually has been there for a while..
this code hasn't been touched by me I believe, so these bugs must have been present for a loooong time...
@EvilOlaf EvilOlaf force-pushed the armbianmonitor-refactor branch from 7a7d2e0 to 5fea993 Compare May 8, 2026 05:09
@igorpecovnik igorpecovnik removed the 02 Milestone: First quarter release label May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release BSP Board Support Packages Needs review Seeking for review size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

3 participants