diff --git a/Partnership/partnership_manager.sh b/Partnership/partnership_manager.sh index f0022bf..a944570 100755 --- a/Partnership/partnership_manager.sh +++ b/Partnership/partnership_manager.sh @@ -1281,7 +1281,7 @@ if [[ "$MODE" == "onboard" ]]; then warn "DRY RUN — would write ACTIVE state and push to remote" fi - # Emby admin provisioning — runs after container deployment (deploy step not yet built) + # Emby admin provisioning — runs after container deployment provision_emby_admin "$MIRROR_IP" # Summary diff --git a/Plugin/unraid/include/common.php b/Plugin/unraid/include/common.php index 546fe3a..4ecc5cf 100644 --- a/Plugin/unraid/include/common.php +++ b/Plugin/unraid/include/common.php @@ -345,7 +345,7 @@ function vv_disk_entry(array $d, string $key, string $role = 'data'): ?array { $mounted = ($d['fsStatus'] ?? '') === 'Mounted'; // Parity has no filesystem — use raw size only $size_kb = (int)($isParity ? ($d['size'] ?? 0) : ($mounted ? ($d['fsSize'] ?? 0) : ($d['size'] ?? 0))); - $used_kb = (int)($isParity ? 0 : ($mounted ? ($d['fsUsed'] ?? 0) : 0)); + $used_kb = (int)($isParity ? 0 : ($d['fsUsed'] ?? 0)); if ($size_kb <= 0) return null; $tempRaw = trim($d['temp'] ?? ''); return [ @@ -472,13 +472,27 @@ function vv_parity_status(): array { ]; } +// Returns a map of disk name → fsUsed in KB from disks.ini. +// Unraid keeps this updated even after spindown, so it's the authoritative source +// for used space when the API reports 0 because the filesystem is unmounted. +function _vv_ini_used_kb(): array { + $ini = @parse_ini_file('/var/local/emhttp/disks.ini', true) ?: []; + $out = []; + foreach ($ini as $key => $d) { + $name = $d['name'] ?? $key; + $out[$name] = (int)($d['fsUsed'] ?? 0); + } + return $out; +} + function vv_storage_pools(): array { // ── API path ────────────────────────────────────────────────────────────── $api = vv_api_data(); if ($api && isset($api['array']['caches'])) { + $ini_used = _vv_ini_used_kb(); $out = []; foreach ($api['array']['caches'] as $d) { - $entry = vv_api_disk_entry($d, 'data'); + $entry = vv_api_disk_entry($d, 'data', $ini_used[$d['name'] ?? ''] ?? 0); if ($entry) $out[] = $entry; } if (!empty($out)) { @@ -505,6 +519,7 @@ function vv_array_disks(): array { // ── API path ────────────────────────────────────────────────────────────── $api = vv_api_data(); if ($api && (isset($api['array']['parities']) || isset($api['array']['disks']))) { + $ini_used = _vv_ini_used_kb(); $parity = []; $data = []; foreach ($api['array']['parities'] ?? [] as $d) { @@ -512,7 +527,7 @@ function vv_array_disks(): array { if ($entry) $parity[] = $entry; } foreach ($api['array']['disks'] ?? [] as $d) { - $entry = vv_api_disk_entry($d, 'data'); + $entry = vv_api_disk_entry($d, 'data', $ini_used[$d['name'] ?? ''] ?? 0); if ($entry) $data[] = $entry; } if (!empty($parity) || !empty($data)) { diff --git a/Plugin/unraid/include/unraid_api.php b/Plugin/unraid/include/unraid_api.php index aa15aec..28d1a3d 100644 --- a/Plugin/unraid/include/unraid_api.php +++ b/Plugin/unraid/include/unraid_api.php @@ -111,7 +111,9 @@ function _vv_api_disk_role(string $type): string { // Build a normalised disk entry from API data, matching the shape vv_disk_entry() produces. // $role may be overridden; if empty it is derived from the disk's type field. -function vv_api_disk_entry(array $d, string $role = ''): ?array { +// $ini_used_kb: last-known fsUsed in KB from disks.ini — used when the disk is +// spun down and the API returns fsUsed=0 because the filesystem is unmounted. +function vv_api_disk_entry(array $d, string $role = '', int $ini_used_kb = 0): ?array { if (!$role) $role = _vv_api_disk_role((string)($d['type'] ?? 'DATA')); if ($role === 'parity') { @@ -127,7 +129,13 @@ function vv_api_disk_entry(array $d, string $role = ''): ?array { if ($sizeRaw <= 0) return null; $usedRaw = (float)($d['fsUsed'] ?? 0); $sizeGb = _vv_api_bytes_to_gb($sizeRaw); - $usedGb = _vv_api_bytes_to_gb($usedRaw); + if ($usedRaw > 0.0) { + $usedGb = _vv_api_bytes_to_gb($usedRaw); + } elseif (!($d['isSpinning'] ?? true) && $ini_used_kb > 0) { + $usedGb = round($ini_used_kb / 1048576, 1); + } else { + $usedGb = 0.0; + } $pct = $sizeGb > 0 ? round($usedGb / $sizeGb * 100, 1) : null; } diff --git a/Plugin/unraid/user_script_plug-in.sh b/Plugin/unraid/user_script_plug-in.sh index db60aef..ed48cda 100755 --- a/Plugin/unraid/user_script_plug-in.sh +++ b/Plugin/unraid/user_script_plug-in.sh @@ -347,9 +347,7 @@ # A reboot between the 14th and 15th will defer maintenance — which is intentional; # heavy tasks (ZFS scrub, SMART long test) should not run on a freshly rebooted system. # -# Configure via master.conf MONTHLY_MAINTENANCE_SCRIPTS. Scripts planned but not yet built: -# zfs_pool_scrub.sh ZFS pool integrity scrub (Tools/) -# smart_long_test.sh SMART extended drive health test (Tools/) +# Configure via master.conf MONTHLY_MAINTENANCE_SCRIPTS — see Tools/zfs_pool_scrub.sh and Tools/smart_long_test.sh. # # bash /boot/config/plugins/varaverk/Orchestrators/monthly_maintenance.sh # bash /boot/config/plugins/varaverk/Orchestrators/monthly_maintenance.sh --dry-run