Consolidate all paths to plugin flash dir, fix watchdog 7.3 triggers
- Move SCRIPTS_DIR/DATA_DIR/STATE_DIR from appdata to /boot/config/plugins/varaverk - All state files now in STATE_DIR (no more /tmp or /boot/config root writes) - Bootstrap: Gitea-first clone with GitHub fallback, no array dependency - varaverk.cfg seeded with Gitea connection settings - .gitignore: add State_Files/, varaverk.cfg, varaverk-*.txz - Partnership/transcode/fallback scripts use STATE_DIR variables - PHP config.php: DATA_DIR/STATE_DIR constants, VV_SETUP_STATE_FILE dynamic - deploy.sh PROD_ROOT updated to plugin flash dir Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
9191a54637
commit
fb0530deba
@@ -142,6 +142,44 @@ function vv_api_disk_entry(array $d, string $role = ''): ?array {
|
||||
];
|
||||
}
|
||||
|
||||
// ── Node metrics extractor ────────────────────────────────────────────────────
|
||||
|
||||
// Parse CPU%, RAM, array storage, disk temps, and VM count from a raw API response.
|
||||
// Used by vv_remote_hosts_stats() and the local vv_api_data() path — one parser, no duplication.
|
||||
// GQL must include: metrics.cpu.percentTotal, metrics.memory.{total,used},
|
||||
// array.{disks,caches,parities}.{fsSize,fsUsed,temp}, vms.domains.
|
||||
function vv_api_node_metrics(?array $d): array {
|
||||
if (!$d) return [];
|
||||
$cpu = (int)round((float)($d['metrics']['cpu']['percentTotal'] ?? 0));
|
||||
$mem = $d['metrics']['memory'] ?? [];
|
||||
$ramUsed = isset($mem['used']) ? _vv_api_bytes_to_gb((float)$mem['used']) : null;
|
||||
$ramTot = isset($mem['total']) ? _vv_api_bytes_to_gb((float)$mem['total']) : null;
|
||||
|
||||
$disks = $d['array']['disks'] ?? [];
|
||||
$caches = $d['array']['caches'] ?? [];
|
||||
$pars = $d['array']['parities'] ?? [];
|
||||
$usedGb = 0.0; $totGb = 0.0;
|
||||
foreach (array_merge($disks, $caches) as $dk) {
|
||||
$sz = (float)($dk['fsSize'] ?? 0);
|
||||
if ($sz <= 0) continue;
|
||||
$totGb += _vv_api_bytes_to_gb($sz);
|
||||
$usedGb += _vv_api_bytes_to_gb((float)($dk['fsUsed'] ?? 0));
|
||||
}
|
||||
$temps = array_filter(
|
||||
array_merge(array_column($disks,'temp'), array_column($caches,'temp'), array_column($pars,'temp')),
|
||||
fn($t) => is_numeric($t) && $t > 0
|
||||
);
|
||||
return [
|
||||
'cpu_pct' => $cpu,
|
||||
'ram_used_gb' => $ramUsed !== null ? round($ramUsed, 1) : null,
|
||||
'ram_total_gb' => $ramTot !== null ? round($ramTot, 1) : null,
|
||||
'array_used_tb' => $totGb > 0 ? round($usedGb / 1000, 1) : null,
|
||||
'array_total_tb' => $totGb > 0 ? round($totGb / 1000, 1) : null,
|
||||
'max_disk_temp' => $temps ? (int)max($temps) : null,
|
||||
'vm_count' => count($d['vms']['domains'] ?? []),
|
||||
];
|
||||
}
|
||||
|
||||
// ── Confirmed schema (Unraid 7.2.5, introspected 2026-05-29) ─────────────────
|
||||
// Adding a new host: add HOSTn="hostname" to master.conf and HOSTn_UNRAID_API_KEY
|
||||
// to hostn.conf, then run Deployment/deploy.sh. No schema work needed.
|
||||
|
||||
Reference in New Issue
Block a user