From 63b1f0a76c8a4bce73d9b97d0bf76d07d4021196 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 31 May 2026 22:40:56 -0400 Subject: [PATCH] feat: cumulative pulled/pushed GB totals in pools and array card headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit disk_io now returns {tr, tw} cumulative GB alongside {r, w} rates. A centered span in each card h3 shows ↓total ↑total (since last boot), updating each poll. Helpers updated for the new object format. Co-Authored-By: Claude Sonnet 4.6 --- Plugin/unraid/include/common.php | 23 +++++++++++++++-------- Plugin/unraid/pages/monitor.php | 25 +++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Plugin/unraid/include/common.php b/Plugin/unraid/include/common.php index 3e29c02..d18daeb 100644 --- a/Plugin/unraid/include/common.php +++ b/Plugin/unraid/include/common.php @@ -559,16 +559,23 @@ function vv_disk_io_rates(): array { // Save current snapshot @file_put_contents($snapFile, json_encode(['t' => $now, 'd' => $current], JSON_UNESCAPED_UNICODE)); - $dt = max(0.5, $now - $prevTime); - $rates = []; + $dt = max(0.5, $now - $prevTime); + $out = []; foreach ($current as $dev => [$rs, $ws]) { - if (!isset($prev[$dev])) continue; - [$prs, $pws] = $prev[$dev]; - $r = max(0.0, ($rs - $prs) * 512 / $dt / 1048576); - $w = max(0.0, ($ws - $pws) * 512 / $dt / 1048576); - if ($r > 0.01 || $w > 0.01) $rates[$dev] = [round($r, 1), round($w, 1)]; + $entry = [ + 'tr' => round($rs * 512 / 1073741824, 2), // cumulative GB read + 'tw' => round($ws * 512 / 1073741824, 2), // cumulative GB written + ]; + if (isset($prev[$dev])) { + [$prs, $pws] = $prev[$dev]; + $r = max(0.0, ($rs - $prs) * 512 / $dt / 1048576); + $w = max(0.0, ($ws - $pws) * 512 / $dt / 1048576); + if ($r > 0.01) $entry['r'] = round($r, 1); + if ($w > 0.01) $entry['w'] = round($w, 1); + } + $out[$dev] = $entry; } - return $rates; + return $out; } function vv_disk_thresholds(): array { diff --git a/Plugin/unraid/pages/monitor.php b/Plugin/unraid/pages/monitor.php index 86cc851..6ef1706 100644 --- a/Plugin/unraid/pages/monitor.php +++ b/Plugin/unraid/pages/monitor.php @@ -158,6 +158,7 @@ Pools +
Loading...
@@ -169,6 +170,7 @@ Array +
Loading...
@@ -515,7 +517,7 @@ function vvFmtRate(mbs) { function vvIoChip(dev) { const io = vvDiskIo[dev]; if (!io) return ''; - const [r, w] = io; + const r = io.r ?? 0, w = io.w ?? 0; if (r < 0.05 && w < 0.05) return ''; const parts = []; if (r >= 0.05) parts.push(`↓${vvFmtRate(r)}`); @@ -524,9 +526,19 @@ function vvIoChip(dev) { } function vvIoSum(devices) { let r = 0, w = 0; - devices.forEach(dev => { const io = vvDiskIo[dev]; if (io) { r += io[0]; w += io[1]; } }); + devices.forEach(dev => { const io = vvDiskIo[dev]; if (io) { r += io.r ?? 0; w += io.w ?? 0; } }); return [r, w]; } +function vvIoTotalSum(devices) { + let tr = 0, tw = 0; + devices.forEach(dev => { const io = vvDiskIo[dev]; if (io) { tr += io.tr ?? 0; tw += io.tw ?? 0; } }); + return [tr, tw]; +} +function vvFmtGb(gb) { + if (gb >= 1024) return (gb / 1024).toFixed(1) + ' TB'; + if (gb >= 1) return gb.toFixed(1) + ' GB'; + return (gb * 1024).toFixed(0) + ' MB'; +} function vvDiskRow(disk) { const tempC = disk.temp; @@ -1233,6 +1245,10 @@ function vvPollMonitor() { ${maxTemp != null ? `· max ${maxTemp}°` : ''} ${ioHtml} `; + const [ptr, ptw] = vvIoTotalSum(disks.map(d => d.device)); + const totEl = document.getElementById('vv-pools-io-total'); + if (totEl && (ptr > 0.001 || ptw > 0.001)) + totEl.innerHTML = `↓${vvFmtGb(ptr)} ↑${vvFmtGb(ptw)}`; } })(); document.getElementById('vv-storage-body').innerHTML = vvRenderPools(vvLastStorageDisks); @@ -1268,6 +1284,11 @@ function vvPollMonitor() { ${arrIoHtml} `; + const [atr, atw] = vvIoTotalSum(arrayDisks.map(d => d.device)); + const arrTotEl = document.getElementById('vv-array-io-total'); + if (arrTotEl && (atr > 0.001 || atw > 0.001)) + arrTotEl.innerHTML = `↓${vvFmtGb(atr)} ↑${vvFmtGb(atw)}`; + const numCols = window.innerWidth <= 1024 ? 2 : Math.max(3, Math.ceil(arrayDisks.length / 6)); const perCol = Math.ceil(arrayDisks.length / numCols); const cols = [];