diff options
| author | Agando <roduccomm@gmail.com> | 2026-06-11 18:00:19 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-06-11 18:00:19 +0200 |
| commit | 76e26bb6f16e35bffbf76896957bb9753241833c (patch) | |
| tree | 25bd27029c2cad1d46208bb3ae026e8272e0a6bf /modules/core/module-servermon.js | |
| parent | c3d5fe64c268d7ca85d1e303b98201391f28c9e9 (diff) | |
auto: 2026-06-11_18:00 changes
Diffstat (limited to 'modules/core/module-servermon.js')
| -rw-r--r-- | modules/core/module-servermon.js | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/modules/core/module-servermon.js b/modules/core/module-servermon.js index 293e9af..b4f6057 100644 --- a/modules/core/module-servermon.js +++ b/modules/core/module-servermon.js @@ -14,7 +14,8 @@ class ServerMonitorModule { 'server-check': 'server-check <name-or-index> — Check a server status', 'server-remove': 'server-remove <name-or-index> — Remove a server', 'monitor': 'monitor — Toggle auto-monitoring (checks every 60s)', - 'system-health': 'system-health — Show tool latency, module load times, VFS size, and error rates' + 'system-health': 'system-health — Show tool latency, module load times, VFS size, and error rates', + 'test-net': 'test-net — Check proxy API, Ollama, and internet connectivity', }; } registerCommands() { @@ -24,6 +25,40 @@ class ServerMonitorModule { this.commands['server-remove'] = (args) => this.removeServer(args); this.commands['monitor'] = (args) => this.toggleMonitor(args); this.commands['system-health'] = () => this.showSystemHealth(); + // v4.5.43: test-net — check proxy/ollama/internet connectivity + this.commands['test-net'] = () => this.testNetwork(); + } + async testNetwork() { + this.terminal.print('🌐 Network Test', 'header'); + // 1. Browser online + const online = navigator.onLine; + this.terminal.print(` ${online ? '✅' : '🔴'} Browser: ${online ? 'online' : 'offline'}`, online ? 'success' : 'error'); + // 2. Proxy API + try { + const t0 = Date.now(); + const resp = await fetch('/api/stats', { signal: AbortSignal.timeout(5000) }); + const ms = Date.now() - t0; + if (resp.ok) { + const data = await resp.json(); + this.terminal.print(` ✅ Proxy: ok (${ms}ms, uptime ${data.uptime_seconds || '?'}s)`, 'success'); + } else { + this.terminal.print(` 🔴 Proxy: HTTP ${resp.status}`, 'error'); + } + } catch (e) { + this.terminal.print(` 🔴 Proxy: ${e.message || 'unreachable'}`, 'error'); + } + // 3. Ollama + const ollamaOk = this.terminal.ollamaManager && this.terminal.ollamaManager.connected; + this.terminal.print(` ${ollamaOk ? '✅' : '🟡'} Ollama: ${ollamaOk ? 'connected' : 'disconnected'}`, ollamaOk ? 'success' : 'warning'); + // 4. Internet (test by fetching a small file) + try { + const t0 = Date.now(); + const resp = await fetch('https://duckduckgo.com/?q=test', { method: 'HEAD', signal: AbortSignal.timeout(5000), mode: 'no-cors' }); + const ms = Date.now() - t0; + this.terminal.print(` ✅ Internet: reachable (${ms}ms)`, 'success'); + } catch (e) { + this.terminal.print(` 🔴 Internet: ${e.message || 'unreachable'}`, 'error'); + } } logToolCall(name, durationMs, error) { this._latencyLog.push({ |