Fallback card: rich state display with tiers, strikes, disabled/suspended
include/monitor.php: vv_fallback_state() now returns:
enabled, check_interval, handback_strikes, handback_strikes_required,
partnership_suspended, partner_lost_at, partnership_required,
partnership_suspend_after — all read from state file + conf vars.
pages/monitor.php: fallback card render rebuilt:
Disabled: clear message with how to enable
Suspended: partnership inactive with elapsed time
FAILOVER: outage duration + T1/T2/T3/T4 tier badges (active=green,
pending=dark) + handback strike progress dots (●●○) when remote
comes back and strikes are counting
NO_INTERNET/DARK: short contextual line
NORMAL: quiet "monitoring · 30s · partnership gated" meta line
Accent border: disabled/suspended → warn, NORMAL → ok, FAILOVER → err
This commit is contained in:
@@ -46,20 +46,39 @@ function vv_partner_state(): array {
|
||||
}
|
||||
|
||||
function vv_fallback_state(): array {
|
||||
// State file written by fallback.sh
|
||||
$vars = vv_conf_vars();
|
||||
$enabled = ($vars['FALLBACK_ENABLED'] ?? 'false') === 'true';
|
||||
$interval = (int)($vars['FALLBACK_CHECK_INTERVAL'] ?? 30);
|
||||
$reqStrikes = (int)($vars['FALLBACK_HANDBACK_STRIKES'] ?? 3);
|
||||
$ptRequired = ($vars['FALLBACK_PARTNERSHIP_REQUIRED'] ?? 'true') === 'true';
|
||||
$suspendAfter = (int)($vars['FALLBACK_PARTNERSHIP_SUSPEND_AFTER'] ?? 120);
|
||||
|
||||
$stateFile = '/tmp/fallback_state.db';
|
||||
if (!file_exists($stateFile)) return ['state' => 'UNKNOWN'];
|
||||
if (!file_exists($stateFile)) {
|
||||
return ['state' => 'UNKNOWN', 'enabled' => $enabled, 'check_interval' => $interval,
|
||||
'handback_strikes' => 0, 'handback_strikes_required' => $reqStrikes,
|
||||
'partnership_required' => $ptRequired, 'partnership_suspended' => false,
|
||||
'partner_lost_at' => 0, 'partnership_suspend_after' => $suspendAfter];
|
||||
}
|
||||
$raw = [];
|
||||
foreach (file($stateFile) ?: [] as $line) {
|
||||
[$k, $v] = array_pad(explode('=', trim($line), 2), 2, '');
|
||||
$raw[trim($k)] = trim($v);
|
||||
}
|
||||
return [
|
||||
'state' => $raw['state'] ?? 'UNKNOWN',
|
||||
'failover_start' => $raw['failover_start'] ?? '0',
|
||||
'tier2_started' => $raw['tier2_started'] ?? 'false',
|
||||
'tier3_started' => $raw['tier3_started'] ?? 'false',
|
||||
'tier4_started' => $raw['tier4_started'] ?? 'false',
|
||||
'state' => $raw['state'] ?? 'UNKNOWN',
|
||||
'failover_start' => $raw['failover_start'] ?? '0',
|
||||
'tier2_started' => $raw['tier2_started'] ?? 'false',
|
||||
'tier3_started' => $raw['tier3_started'] ?? 'false',
|
||||
'tier4_started' => $raw['tier4_started'] ?? 'false',
|
||||
'handback_strikes' => (int)($raw['handback_strikes'] ?? 0),
|
||||
'partnership_suspended' => ($raw['partnership_suspended'] ?? 'false') === 'true',
|
||||
'partner_lost_at' => (int)($raw['partner_lost_at'] ?? 0),
|
||||
'enabled' => $enabled,
|
||||
'check_interval' => $interval,
|
||||
'handback_strikes_required' => $reqStrikes,
|
||||
'partnership_required' => $ptRequired,
|
||||
'partnership_suspend_after' => $suspendAfter,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user