Skip to content

Conversation

@DerekChan65535
Copy link

@DerekChan65535 DerekChan65535 commented Sep 17, 2025

Summary by CodeRabbit

  • New Features
    • Added a per-disk utilization (%) metric to device and pool views, including boot and open devices.
    • Expanded IO reporting to include the new metric in live updates and totals.
  • Refactor
    • Updated table layouts to include the new column, ensuring consistent alignment across array, pool, and totals rows.
    • Adjusted colspans and status/preclear blocks to match the expanded table structure.
    • Harmonized “Slots” and other header rows with the new column for consistent presentation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 17, 2025

Walkthrough

Extends per-disk IO data to include a new utilization metric, updates data collection to read six fields from /proc/diskstats, and adjusts UI rendering to add a new percentage column. All related table colspans and totals/slots/preclear sections are incremented to align with the additional column.

Changes

Cohort / File(s) Summary of Changes
Data collection: disk utilization metric
emhttp/plugins/dynamix/nchan/disk_load
Reads six fields per device from /proc/diskstats, adds use_time tracking, computes util percentage (clamped to 100), updates output format to include util, and shifts index arithmetic from 5-field to 6-field blocks.
UI rendering: extra column and colspan updates
emhttp/plugins/dynamix/nchan/device_list
Expands IO data vector usages to accommodate an extra value; renders a new percentage column (data[4]) across array, pool, boot, and open device rows; increments related colspan values (e.g., 8→9, 4→5); adjusts totals, slots, and preclear/status blocks for alignment.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Kernel as Kernel (/proc/diskstats)
  participant DiskLoad as nchan/disk_load
  participant Nchan as nchan broker
  participant DeviceList as nchan/device_list (renderer)
  participant Browser as Web UI

  Note over DiskLoad: Initialization
  Kernel-->>DiskLoad: Read per-disk stats (6 fields)
  DiskLoad->>DiskLoad: Store reads/writes/use_time

  Note over DiskLoad: Poll loop (interval t)
  Kernel-->>DiskLoad: Read updated stats (6 fields)
  DiskLoad->>DiskLoad: Compute util = Δuse_time / (t·1000) · 100<br/>Clamp to 0–100
  DiskLoad-->>Nchan: Publish metrics [reads, writes, ..., util]

  Nchan-->>DeviceList: Push updated metrics
  DeviceList->>DeviceList: Map data[4] → percentage column<br/>Adjust colspans/totals/slots
  DeviceList-->>Browser: Render table with new % column
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my ears at numbers’ hum,
Six beats per disk—here util comes!
New columns bloom in tidy rows,
Percentages like clover grows.
I thump: “Aligned!” with table might,
Carrots up for stats done right.
Hop, hop—the dashboards light! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Feat: Add disk utilization column to webUI" succinctly and accurately describes the primary change in the patch—adding a per-disk utilization metric and a new percentage column to the web UI—as reflected in the raw_summary changes to device_list and disk_load. It is concise, specific, and focuses on the main user-visible feature rather than implementation details, so it conveys the intent clearly to reviewers. The phrasing is appropriate for PR history and release notes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

Copy link
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)
emhttp/plugins/dynamix/nchan/device_list (1)

303-307: Colspan off by one in DISK_NP_DSBL (online).

This path still uses colspan='4', but the table now has one extra column. Use 5 to align.

-    $echo[] = "<td colspan='4'></td>";
+    $echo[] = "<td colspan='5'></td>";
🧹 Nitpick comments (5)
emhttp/plugins/dynamix/nchan/disk_load (4)

10-10: Anchor to device field and include all NVMe namespaces.

Limit the AWK match to $3 (device name) and support nvmeNnM (not only n1) to avoid false matches and omissions.

-stats=($(awk '/(sd[a-z]*|nvme[0-9]*n1|vd[a-z]*) /{print $3,$6,$10,$4,$8,$13}' /proc/diskstats))
+stats=($(awk '$3 ~ /^(sd[a-z]+|nvme[0-9]+n[0-9]+|vd[a-z]+)$/{print $3,$6,$10,$4,$8,$13}' /proc/diskstats))

And similarly inside the loop:

-  stats=($(awk '/(sd[a-z]*|nvme[0-9]*n1|vd[a-z]*) /{print $3,$6,$10,$4,$8,$13}' /proc/diskstats))
+  stats=($(awk '$3 ~ /^(sd[a-z]+|nvme[0-9]+n[0-9]+|vd[a-z]+)$/{print $3,$6,$10,$4,$8,$13}' /proc/diskstats))

Also applies to: 21-21


23-31: Clamp util to [0,100] and handle counter reset/wrap.

Negative deltas can occur after device reset or wrap. Guard and clamp.

-    util=$((((stats[i+5]-use_time[c])*100)/(t*1000)))
-    if [ $util -gt 100 ]; then util=100; fi
+    delta_ms=$((stats[i+5]-use_time[c]))
+    if [ $delta_ms -lt 0 ]; then delta_ms=0; fi
+    util=$(( (delta_ms*100)/(t*1000) ))
+    if [ $util -gt 100 ]; then util=100; fi
+    if [ $util -lt 0 ]; then util=0; fi

20-20: Ensure atomic refresh by truncating the temp file each cycle.

If the script crashes before mv, a stale tmp file could accumulate lines. Truncate at loop start.

 while :; do
-  stats=($(awk '$3 ~ /^(sd[a-z]+|nvme[0-9]+n[0-9]+|vd[a-z]+)$/{print $3,$6,$10,$4,$8,$13}' /proc/diskstats))
+  : > "$tmp"
+  stats=($(awk '$3 ~ /^(sd[a-z]+|nvme[0-9]+n[0-9]+|vd[a-z]+)$/{print $3,$6,$10,$4,$8,$13}' /proc/diskstats))

Also applies to: 28-28


4-4: Consider keying history by device name (associative arrays).

Indexing by position breaks if device enumeration order changes between polls. Associative arrays keyed by ${stats[i]} would be more robust.

emhttp/plugins/dynamix/nchan/device_list (1)

315-315: Nit: format util as integer with non-breaking space.

Optional polish for consistency with other numeric cells.

-    $echo[] = "<td>" . (_var($data, 4, 0)) . " %</td>";
+    $echo[] = "<td>" . intval(_var($data, 4, 0)) . "&nbsp;%</td>";

Also applies to: 496-496, 558-558

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d05f8aa and 190c0f6.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/nchan/device_list (14 hunks)
  • emhttp/plugins/dynamix/nchan/disk_load (1 hunks)
🔇 Additional comments (3)
emhttp/plugins/dynamix/nchan/device_list (3)

298-298: LGTM on new util column and matching totals/colspans.

  • Rendering new “% util” cell (Line 315/496/558): OK.
  • Totals row placeholder “-” (Line 339): OK.
  • Updated colspans for added column in several spots (Lines 298, 356, 473, 485, 549): OK.

Also applies to: 315-315, 339-339, 356-356, 473-473, 485-485, 496-496, 549-549, 558-558


219-219: LGTM on offline-path colspan adjustments.

Updated spans line up with the added util column across offline states.

Also applies to: 224-225, 231-233, 244-249, 256-261


272-276: LGTM on widened diskio vector parsing.

Defaulting to five values and summing reads/writes matches the producer format.

Comment on lines 564 to 566
} else {
$echo[$a][] = "<td colspan='4'></td>";
$echo[$a][] = "<td colspan='5'></td>";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Open devices preclear/info colspans should be 4, not 5.

Row now has 7 cells before the filler. To reach 11, use colspan='4'.

-      $echo[$a][] = "<td colspan='5'><em>$text</em></td>";
+      $echo[$a][] = "<td colspan='4'><em>$text</em></td>";
 ...
-      $echo[$a][] = "<td colspan='5'></td>";
+      $echo[$a][] = "<td colspan='4'></td>";
📝 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
} else {
$echo[$a][] = "<td colspan='4'></td>";
$echo[$a][] = "<td colspan='5'></td>";
}
} else {
$echo[$a][] = "<td colspan='4'></td>";
}
🤖 Prompt for AI Agents
In emhttp/plugins/dynamix/nchan/device_list around lines 564 to 566, the filler
cell uses colspan='5' but the row already contains 7 cells before the filler so
the filler should be colspan='4' to make the total 11; change the hardcoded
colspan value from 5 to 4 in that else branch so the table layout aligns
correctly.

@ljm42 ljm42 added the TBD label Sep 17, 2025
@github-actions
Copy link

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2025.09.17.1800
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2375/webgui-pr-2375.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates

📝 Modified Files:

Click to expand file list
emhttp/plugins/dynamix/nchan/device_list
emhttp/plugins/dynamix/nchan/disk_load

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2025.09.17.1800, or run:

plugin remove webgui-pr-2025.09.17.1800

🤖 This comment is automatically generated and will be updated with each new push to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants