Add structured headers to the PHP include layer, fix monitor state paths
All 16 include/ files now carry PURPOSE / DESIGN PRINCIPLES / OPERATIONAL SAFEGUARDS / EXPORTS / CONFIGURATION, keeping the first three section names identical to the bash headers so retrieval can route across both languages. monitor.php read six watchdog state files from /tmp while the watchdogs write to STATE_DIR, so every strike set came back empty and the summary reported healthy unconditionally. docs.php gained path containment before it is wired to a page.
This commit is contained in:
@@ -1,4 +1,48 @@
|
||||
<?php
|
||||
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
||||
// PURPOSE
|
||||
// Unraid GraphQL API client. Issues one combined query per request for OS, CPU, memory,
|
||||
// disks and array state, and records which callers had to fall back when the API is
|
||||
// unavailable.
|
||||
//
|
||||
// DESIGN PRINCIPLES
|
||||
// One round trip per request, not one per metric.
|
||||
// vv_api_data() runs a single combined query and caches it for the lifetime of the
|
||||
// request. A page reading eight metrics still makes one API call.
|
||||
//
|
||||
// Fallback is expected, and it is tracked.
|
||||
// The unraid-api registry is ephemeral — a key that worked yesterday can be gone.
|
||||
// Every function that had to use a local path records itself via
|
||||
// vv_api_record_fallback(), so vv_api_get_status() can report precisely which data is
|
||||
// degraded rather than a single unhelpful "API down".
|
||||
//
|
||||
// The API is an optimisation, never a dependency.
|
||||
// Every value it provides has a local path in common.php. Losing the API costs detail
|
||||
// and precision, not availability.
|
||||
//
|
||||
// OPERATIONAL SAFEGUARDS
|
||||
// Absent or invalid key degrades silently to local reads.
|
||||
// No exception, no error banner — the caller gets its value from /proc or sysfs and the
|
||||
// fallback is recorded for the status endpoint.
|
||||
//
|
||||
// Request-lifetime cache only.
|
||||
// Nothing is persisted to disk here, so a stale API response cannot outlive the page
|
||||
// that fetched it.
|
||||
//
|
||||
// Read-only. Queries state; issues no mutations against unraid-api.
|
||||
//
|
||||
// EXPORTS
|
||||
// vv_api_data() the combined query result, cached per request
|
||||
// vv_api_get_status() availability plus the list of functions that fell back
|
||||
// vv_api_record_fallback() called by consumers when they use a local path instead
|
||||
// vv_api_node_metrics() per-node metric summary
|
||||
// vv_api_disk_entry() normalised disk record
|
||||
// vv_local_host_stats() local summary in the same shape as a remote node
|
||||
//
|
||||
// CONFIGURATION
|
||||
// HOST*_UNRAID_API_KEY written every array start and every 15 min by
|
||||
// Plugin/unraid/System_Essentials/unraid_api_key_renew.sh
|
||||
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
||||
// Unraid GraphQL API — single-request master fetch + per-function fallback tracking.
|
||||
// All API-first functions call vv_api_data() then fall back to local reads on null.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user