From c2a658c61c252722892ffc5967bf7fe88d6c04bf Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Wed, 2 Oct 2024 05:21:43 -0400 Subject: [PATCH] update AI page --- public/js/chat.js | 113 ---------------------------------------------- views/chat.ejs | 26 ++--------- 2 files changed, 4 insertions(+), 135 deletions(-) diff --git a/public/js/chat.js b/public/js/chat.js index 4ee67dd..bf8456d 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -212,116 +212,3 @@ function openTop() { window.open('https://ai-top.x64.world/', 'liveLogGtopWindow', 'width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes'); } -const NETDATA_URL = 'https://ai-monitor.x64.world'; - -// Function to fetch data from the Netdata API -async function fetchData(chart) { - const response = await fetch(`${NETDATA_URL}/api/v1/data?chart=${chart}&format=json`, { - cache: 'no-store', - headers: { - 'Cache-Control': 'no-cache' - } - }); - return await response.json(); -} - -// Function to update all metrics every 2 seconds -async function updateMetrics() { - await updateCpuUsage(); - await updateMemoryUsage(); - await updateNetworkUsage(); - await fetchGpuStats(); // Fetch GPU stats too - - setTimeout(updateMetrics, 2000); -} - -// Function to update CPU usage -async function updateCpuUsage() { - const data = await fetchData('system.cpu'); - const totalCPU = data.data[0].slice(1).reduce((acc, curr) => acc + curr, 0); - document.getElementById('cpuUsageItem').textContent = `CPU Usage: ${totalCPU.toFixed(2)}%`; -} - -// Function to update Memory usage -async function updateMemoryUsage() { - const data = await fetchData('mem.available'); - const usedMemoryMB = data.data[0][1]; - const usedMemoryGB = usedMemoryMB / 1024; - document.getElementById('memoryUsageItem').textContent = `Memory Usage: ${usedMemoryGB.toFixed(2)} GB`; -} - -// Function to update Network usage -async function updateNetworkUsage() { - const data = await fetchData('system.net'); - const totalNetwork = data.data[0].slice(1).reduce((acc, curr) => acc + curr, 0); - - let networkText; - if (totalNetwork > 1024) { - const totalNetworkInMB = totalNetwork / 1024; - networkText = `${totalNetworkInMB.toFixed(2)} MB/s (Down)`; - } else if (totalNetwork < -1024) { - const totalNetworkInMB = Math.abs(totalNetwork) / 1024; - networkText = `${totalNetworkInMB.toFixed(2)} MB/s (Up)`; - } else { - const totalNetworkInKB = Math.abs(totalNetwork); - networkText = `${totalNetworkInKB.toFixed(2)} KB/s (Up)`; - } - document.getElementById('networkUsageItem').textContent = `Network Usage: ${networkText}`; -} - -// Function to fetch GPU stats -async function fetchGpuStats() { - try { - const response = await fetch('https://smi.x64.world/nvidia-smi'); - const data = await response.json(); - updateGpuStats(data); - } catch (error) { - console.error('Error fetching GPU stats:', error); - } -} - -// Function to update GPU stats -function updateGpuStats(data) { - const gpu = data.nvidia_smi_log.gpu; - document.getElementById('gpuUsageItem').textContent = `GPU Utilization: ${gpu.utilization.gpu_util}%`; - document.getElementById('gpuMemoryUsageItem').textContent = `GPU Memory Utilization: ${gpu.utilization.memory_util}%`; -} - -// Function to initialize the dynamic menu items -function initializeMenu() { - const menu = document.getElementById('monitorMenu'); - - // Create CPU Usage item - const cpuItem = document.createElement('li'); - cpuItem.classList.add('nav-item'); - cpuItem.innerHTML = 'CPU Usage: --%'; - menu.appendChild(cpuItem); - - // Create Memory Usage item - const memoryItem = document.createElement('li'); - memoryItem.classList.add('nav-item'); - memoryItem.innerHTML = 'Memory Usage: -- GB'; - menu.appendChild(memoryItem); - - // Create Network Usage item - const networkItem = document.createElement('li'); - networkItem.classList.add('nav-item'); - networkItem.innerHTML = 'Network Usage: -- KB/s'; - menu.appendChild(networkItem); - - // Create GPU Usage item - const gpuItem = document.createElement('li'); - gpuItem.classList.add('nav-item'); - gpuItem.innerHTML = 'GPU Utilization: --%'; - menu.appendChild(gpuItem); - - // Create GPU Memory Utilization item - const gpuMemoryItem = document.createElement('li'); - gpuMemoryItem.classList.add('nav-item'); - gpuMemoryItem.innerHTML = 'GPU Memory Utilization: --%'; - menu.appendChild(gpuMemoryItem); -} - -// Start the updates -initializeMenu(); -updateMetrics(); \ No newline at end of file diff --git a/views/chat.ejs b/views/chat.ejs index 5054ee0..46b40d5 100644 --- a/views/chat.ejs +++ b/views/chat.ejs @@ -62,38 +62,20 @@ | - + - - - - - - - -