Shorten agent health checks on load

This commit is contained in:
James Smith
2026-03-19 08:09:07 +00:00
parent db0a26cd64
commit fb8b6a01e8
2 changed files with 80 additions and 53 deletions

View File

@@ -10,10 +10,11 @@ let currentAgent = 'local';
let agentEventSource = null;
let multiAgentMode = false; // Show combined results from all agents
let multiAgentPollInterval = null;
let agentRunningModes = []; // Track agent's running modes for conflict detection
let agentRunningModesDetail = {}; // Track device info per mode (for multi-SDR agents)
let healthCheckInterval = null; // Health monitoring interval
let agentHealthStatus = {}; // Cache of health status per agent ID
let agentRunningModes = []; // Track agent's running modes for conflict detection
let agentRunningModesDetail = {}; // Track device info per mode (for multi-SDR agents)
let healthCheckInterval = null; // Health monitoring interval
let agentHealthStatus = {}; // Cache of health status per agent ID
let healthCheckKickoffTimer = null;
// ============== AGENT HEALTH MONITORING ==============
@@ -21,27 +22,38 @@ let agentHealthStatus = {}; // Cache of health status per agent ID
* Start periodic health monitoring for all agents.
* Runs every 30 seconds to check agent health status.
*/
function startHealthMonitoring() {
// Don't start if already running
if (healthCheckInterval) return;
// Initial check
checkAllAgentsHealth();
// Start periodic checks every 30 seconds
healthCheckInterval = setInterval(checkAllAgentsHealth, 30000);
console.log('[AgentManager] Health monitoring started (30s interval)');
}
function startHealthMonitoring() {
// Don't start if already running
if (healthCheckInterval) return;
// Defer the first probe so heavy dashboards can finish initial render
// before we start contacting remote agents.
if (healthCheckKickoffTimer) {
clearTimeout(healthCheckKickoffTimer);
}
healthCheckKickoffTimer = setTimeout(() => {
healthCheckKickoffTimer = null;
checkAllAgentsHealth();
}, 5000);
// Start periodic checks every 30 seconds
healthCheckInterval = setInterval(checkAllAgentsHealth, 30000);
console.log('[AgentManager] Health monitoring started (30s interval)');
}
/**
* Stop health monitoring.
*/
function stopHealthMonitoring() {
if (healthCheckInterval) {
clearInterval(healthCheckInterval);
healthCheckInterval = null;
console.log('[AgentManager] Health monitoring stopped');
}
function stopHealthMonitoring() {
if (healthCheckKickoffTimer) {
clearTimeout(healthCheckKickoffTimer);
healthCheckKickoffTimer = null;
}
if (healthCheckInterval) {
clearInterval(healthCheckInterval);
healthCheckInterval = null;
console.log('[AgentManager] Health monitoring stopped');
}
}
/**