aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-servermon.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/module-servermon.js')
-rw-r--r--modules/core/module-servermon.js37
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({