(nodes, links, deviceColors, deviceIcons)
| 21057 | fetchNetworkStats(); |
| 21058 | |
| 21059 | // Auto-refresh every 5 seconds when on system tab |
| 21060 | if (systemMonitoringInterval) { |
| 21061 | clearInterval(systemMonitoringInterval); |
| 21062 | } |
| 21063 | |
| 21064 | systemMonitoringInterval = setInterval(() => { |
| 21065 | if (currentTab === 'system') { |
| 21066 | fetchSystemStatus(); |
| 21067 | fetchNetworkStats(); |
| 21068 | } |
| 21069 | }, 5000); |
| 21070 | } |
| 21071 | |
| 21072 | function fetchSystemStatus() { |
| 21073 | networkAwareFetch('/api/system/status') |
| 21074 | .then(response => response.json()) |
| 21075 | .then(data => { |
| 21076 | if (data.error) { |
| 21077 | showSystemError('Failed to load system status: ' + data.error); |
| 21078 | return; |
| 21079 | } |
| 21080 | updateSystemOverview(data); |
| 21081 | updateProcessList(data.processes); |
| 21082 | updateNetworkInterfaces(data.network_interfaces); |
| 21083 | updateTemperatureDisplay(data.temperatures); |
| 21084 | }) |
| 21085 | .catch(error => { |
| 21086 | console.error('Error fetching system status:', error); |
| 21087 | showSystemError('Failed to load system status'); |
| 21088 | }); |
| 21089 | } |
| 21090 | |
| 21091 | function fetchNetworkStats() { |
| 21092 | networkAwareFetch('/api/system/network-stats') |
| 21093 | .then(response => response.json()) |
| 21094 | .then(data => { |
| 21095 | if (data.error) { |
| 21096 | console.error('Network stats error:', data.error); |
| 21097 | return; |
| 21098 | } |
| 21099 | updateNetworkStats(data); |
| 21100 | }) |
| 21101 | .catch(error => { |
| 21102 | console.error('Error fetching network stats:', error); |
| 21103 | }); |
| 21104 | } |
| 21105 | |
| 21106 | function updateSystemOverview(data) { |
| 21107 | // CPU |
| 21108 | const cpuUsage = document.getElementById('cpu-usage'); |
| 21109 | const cpuDetails = document.getElementById('cpu-details'); |
| 21110 | const cpuProgress = document.getElementById('cpu-progress'); |
| 21111 | |
| 21112 | if (cpuUsage) cpuUsage.textContent = `${data.cpu.percent}%`; |
| 21113 | if (cpuDetails) cpuDetails.textContent = `${data.cpu.count} cores`; |
| 21114 | if (cpuProgress) cpuProgress.style.width = `${data.cpu.percent}%`; |
| 21115 | |
| 21116 | // Memory |
no test coverage detected