Spaces:
Running
Running
Jair Adair dos Soares Almeida commited on
Add 3 files
Browse filesFiles changed (3)
- README.md+5-3
- index.html+624-19
- prompts.txtAdded+3
12345678910---title: Cpm Igremoji: 💻colorFrom: bluecolorTo: yellowsdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112---title: cpm-igremoji: 🐳colorFrom: bluecolorTo: yellowsdk: staticpinned: falsetags:- deepsite---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Network Device Monitor</title><script src="https://cdn.tailwindcss.com"></script><script src="https://cdn.jsdelivr.net/npm/chart.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><style>.status-online {background-color: #10b981;animation: pulse-green 2s infinite;}.status-offline {background-color: #ef4444;animation: pulse-red 2s infinite;}@keyframes pulse-green {0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }}@keyframes pulse-red {0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }}.fade-in {animation: fadeIn 0.5s;}@keyframes fadeIn {from { opacity: 0; }to { opacity: 1; }}.rotate {animation: rotation 2s infinite linear;}@keyframes rotation {from { transform: rotate(0deg); }to { transform: rotate(359deg); }}body {background-color: #1a1a1a;color: #e5e7eb;}.card {background-color: #2d2d2d;border: 1px solid #3d3d3d;}.table-header {background-color: #252525;}.table-row {border-color: #3d3d3d;}.table-cell {color: #e5e7eb;}.input-dark {background-color: #3d3d3d;border-color: #4d4d4d;color: #e5e7eb;}.input-dark:focus {border-color: #6366f1;box-shadow: 0 0 0 1px #6366f1;}</style></head><body class="bg-gray-900"><div class="container mx-auto px-4 py-8"><div class="flex justify-between items-center mb-8"><h1 class="text-3xl font-bold text-gray-100"><i class="fas fa-network-wired mr-2 text-blue-400"></i> Network Device Monitor</h1><div class="flex items-center space-x-4"><div class="relative"><input type="file" id="fileInput" accept=".xlsx,.xls" class="hidden"><label for="fileInput" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg cursor-pointer flex items-center transition-colors"><i class="fas fa-file-excel mr-2"></i> Load Excel</label></div></div></div><div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8"><!-- Control Panel --><div class="card rounded-xl shadow-md p-6 col-span-1"><h2 class="text-xl font-semibold mb-4 text-gray-200"><i class="fas fa-sliders-h mr-2 text-blue-400"></i> Control Panel</h2><div class="space-y-4"><div><label class="block text-sm font-medium text-gray-300 mb-1">Ping Interval (seconds)</label><input type="number" id="pingInterval" min="1" value="5" class="w-full px-3 py-2 input-dark rounded-md focus:outline-none"></div><div class="flex space-x-3"><button id="startPing" class="flex-1 bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center justify-center transition-colors"><i class="fas fa-play mr-2"></i> Start Ping</button><button id="stopPing" class="flex-1 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center justify-center transition-colors" disabled><i class="fas fa-stop mr-2"></i> Stop Ping</button></div><div class="pt-4 border-t border-gray-700"><div class="flex items-center"><div class="w-3 h-3 rounded-full status-online mr-2"></div><span class="text-sm text-gray-300">Online: <span id="onlineCount" class="font-medium">0</span></span></div><div class="flex items-center mt-1"><div class="w-3 h-3 rounded-full status-offline mr-2"></div><span class="text-sm text-gray-300">Offline: <span id="offlineCount" class="font-medium">0</span></span></div></div></div></div><!-- Uptime Stats --><div class="card rounded-xl shadow-md p-6 col-span-1"><h2 class="text-xl font-semibold mb-4 text-gray-200"><i class="fas fa-chart-pie mr-2 text-blue-400"></i> Uptime Statistics</h2><div class="h-40"><canvas id="uptimeChart"></canvas></div><div class="mt-4 text-center"><p class="text-sm text-gray-400">Average Uptime: <span id="avgUptime" class="font-semibold text-gray-200">0%</span></p></div></div><!-- Response Time Stats --><div class="card rounded-xl shadow-md p-6 col-span-1"><h2 class="text-xl font-semibold mb-4 text-gray-200"><i class="fas fa-stopwatch mr-2 text-blue-400"></i> Response Time</h2><div class="h-40"><canvas id="responseTimeChart"></canvas></div><div class="mt-4 text-center"><p class="text-sm text-gray-400">Avg Response: <span id="avgResponse" class="font-semibold text-gray-200">0 ms</span></p></div></div></div><!-- Device Table --><div class="card rounded-xl shadow-md overflow-hidden mb-8"><div class="px-6 py-4 border-b border-gray-700 flex justify-between items-center"><h2 class="text-xl font-semibold text-gray-200"><i class="fas fa-table mr-2 text-blue-400"></i> Device Status</h2><div class="text-sm text-gray-400">Last updated: <span id="lastUpdated" class="text-gray-300">Never</span></div></div><div class="overflow-x-auto"><table class="min-w-full divide-y divide-gray-700"><thead class="table-header"><tr><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">USER NAME</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">IGG</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">HOST NAME</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">IP ADDRESS</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">STATUS</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">LAST PING TIME</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">RESPONSE TIME</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">UPTIME</th></tr></thead><tbody id="deviceTableBody" class="divide-y divide-gray-700"><tr class="table-row"><td colspan="8" class="px-6 py-4 text-center text-gray-400">No devices loaded. Please upload an Excel file.</td></tr></tbody></table></div></div><!-- Timeline Chart --><div class="card rounded-xl shadow-md p-6 mb-8"><h2 class="text-xl font-semibold mb-4 text-gray-200"><i class="fas fa-chart-line mr-2 text-blue-400"></i> Response Time History</h2><div class="h-80"><canvas id="timelineChart"></canvas></div></div></div><script>// Global variableslet devices = [];let pingIntervalId = null;let pingHistory = {};let chartData = {labels: [],datasets: []};// Initialize charts with dark themeconst uptimeCtx = document.getElementById('uptimeChart').getContext('2d');const responseTimeCtx = document.getElementById('responseTimeChart').getContext('2d');const timelineCtx = document.getElementById('timelineChart').getContext('2d');Chart.defaults.color = '#e5e7eb';Chart.defaults.borderColor = '#3d3d3d';const uptimeChart = new Chart(uptimeCtx, {type: 'doughnut',data: {labels: ['Online', 'Offline'],datasets: [{data: [0, 0],backgroundColor: ['#10b981', '#ef4444'],borderWidth: 0}]},options: {responsive: true,maintainAspectRatio: false,cutout: '70%',plugins: {legend: {position: 'bottom',labels: {color: '#e5e7eb'}}}}});const responseTimeChart = new Chart(responseTimeCtx, {type: 'bar',data: {labels: ['<50ms', '50-100ms', '100-200ms', '>200ms'],datasets: [{label: 'Response Time Distribution',data: [0, 0, 0, 0],backgroundColor: ['#10b981','#a3e635','#facc15','#ef4444'],borderWidth: 0}]},options: {responsive: true,maintainAspectRatio: false,scales: {y: {beginAtZero: true,grid: {color: '#3d3d3d'}},x: {grid: {color: '#3d3d3d'}}},plugins: {legend: {display: false}}}});const timelineChart = new Chart(timelineCtx, {type: 'line',data: {labels: [],datasets: []},options: {responsive: true,maintainAspectRatio: false,scales: {y: {beginAtZero: true,title: {display: true,text: 'Response Time (ms)',color: '#e5e7eb'},grid: {color: '#3d3d3d'}},x: {title: {display: true,text: 'Time',color: '#e5e7eb'},grid: {color: '#3d3d3d'}}},plugins: {tooltip: {mode: 'index',intersect: false,backgroundColor: '#2d2d2d',titleColor: '#e5e7eb',bodyColor: '#e5e7eb',borderColor: '#3d3d3d'},legend: {position: 'bottom',labels: {color: '#e5e7eb'}}},interaction: {mode: 'nearest',axis: 'x',intersect: false}}});// DOM elementsconst fileInput = document.getElementById('fileInput');const startPingBtn = document.getElementById('startPing');const stopPingBtn = document.getElementById('stopPing');const pingIntervalInput = document.getElementById('pingInterval');const deviceTableBody = document.getElementById('deviceTableBody');const onlineCount = document.getElementById('onlineCount');const offlineCount = document.getElementById('offlineCount');const avgUptime = document.getElementById('avgUptime');const avgResponse = document.getElementById('avgResponse');const lastUpdated = document.getElementById('lastUpdated');// Event listenersfileInput.addEventListener('change', handleFileUpload);startPingBtn.addEventListener('click', startPing);stopPingBtn.addEventListener('click', stopPing);// Functionsfunction handleFileUpload(e) {const file = e.target.files[0];if (!file) return;const reader = new FileReader();reader.onload = function(e) {const data = new Uint8Array(e.target.result);const workbook = XLSX.read(data, { type: 'array' });const firstSheet = workbook.Sheets[workbook.SheetNames[0]];const jsonData = XLSX.utils.sheet_to_json(firstSheet);devices = jsonData.map(device => ({userName: device['USER NAME'] || '',igg: device['IGG'] || '',hostName: device['HOST NAME'] || '',ipAddress: device['IP ADDRESS'] || '',status: 'offline', // Todas as máquinas começam como offlinelastPingTime: '',responseTime: 0,uptime: 0,checks: 0,onlineChecks: 0}));// Initialize ping historydevices.forEach(device => {if (!pingHistory[device.hostName || device.ipAddress]) {pingHistory[device.hostName || device.ipAddress] = [];}});renderDeviceTable();updateStats();};reader.readAsArrayBuffer(file);}function renderDeviceTable() {if (devices.length === 0) {deviceTableBody.innerHTML = '<tr class="table-row"><td colspan="8" class="px-6 py-4 text-center text-gray-400">No devices loaded. Please upload an Excel file.</td></tr>';return;}deviceTableBody.innerHTML = devices.map(device => `<tr class="table-row fade-in"><td class="px-6 py-4 whitespace-nowrap text-sm table-cell">${device.userName}</td><td class="px-6 py-4 whitespace-nowrap text-sm table-cell">${device.igg}</td><td class="px-6 py-4 whitespace-nowrap text-sm table-cell">${device.hostName}</td><td class="px-6 py-4 whitespace-nowrap text-sm table-cell">${device.ipAddress}</td><td class="px-6 py-4 whitespace-nowrap"><span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${device.status === 'online' ? 'bg-green-900 text-green-200' : 'bg-red-900 text-red-200'}">${device.status === 'online' ? 'Online' : 'Offline'}</span></td><td class="px-6 py-4 whitespace-nowrap text-sm table-cell">${device.lastPingTime || 'Never'}</td><td class="px-6 py-4 whitespace-nowrap text-sm table-cell">${device.responseTime ? `${device.responseTime} ms` : '-'}</td><td class="px-6 py-4 whitespace-nowrap text-sm table-cell">${device.checks > 0 ? `${Math.round((device.onlineChecks / device.checks) * 100)}%` : '0%'}</td></tr>`).join('');}function updateStats() {const onlineDevices = devices.filter(d => d.status === 'online').length;const offlineDevices = devices.filter(d => d.status === 'offline').length;onlineCount.textContent = onlineDevices;offlineCount.textContent = offlineDevices;// Update uptime chartuptimeChart.data.datasets[0].data = [onlineDevices, offlineDevices];uptimeChart.update();// Calculate average uptimeconst avg = devices.length > 0 ?devices.reduce((sum, device) => sum + (device.checks > 0 ? (device.onlineChecks / device.checks) : 0), 0) / devices.length * 100 : 0;avgUptime.textContent = `${Math.round(avg)}%`;// Calculate response time distributionconst responseTimes = devices.filter(d => d.status === 'online').map(d => d.responseTime);const dist = [0, 0, 0, 0]; // <50, 50-100, 100-200, >200responseTimes.forEach(time => {if (time < 50) dist[0]++;else if (time < 100) dist[1]++;else if (time < 200) dist[2]++;else dist[3]++;});responseTimeChart.data.datasets[0].data = dist;responseTimeChart.update();// Calculate average response timeconst avgResp = responseTimes.length > 0 ?Math.round(responseTimes.reduce((sum, time) => sum + time, 0) / responseTimes.length) : 0;avgResponse.textContent = `${avgResp} ms`;// Update last updated timelastUpdated.textContent = new Date().toLocaleString();}function updateTimelineChart() {const now = new Date();const labels = Array.from({ length: 10 }, (_, i) => {const d = new Date(now);d.setMinutes(d.getMinutes() - (9 - i));return d.toLocaleTimeString();});const datasets = devices.slice(0, 5).map((device, i) => {const history = pingHistory[device.hostName || device.ipAddress] || [];const data = Array(10).fill(null);// Fill the last 10 minutes of datahistory.slice(-10).forEach((entry, j) => {const timeDiff = (now - new Date(entry.time)) / (1000 * 60); // minutes agoconst pos = 9 - Math.min(9, Math.floor(timeDiff));if (pos >= 0 && pos < 10) {data[pos] = entry.responseTime;}});return {label: device.hostName || device.ipAddress,data: data,borderColor: getColor(i),backgroundColor: 'rgba(0, 0, 0, 0)',tension: 0.3,fill: false,pointRadius: 3,pointHoverRadius: 5};});timelineChart.data.labels = labels;timelineChart.data.datasets = datasets;timelineChart.update();}function getColor(index) {const colors = ['#6366f1', // indigo-500'#ec4899', // pink-500'#14b8a6', // teal-500'#f59e0b', // amber-500'#8b5cf6' // violet-500];return colors[index % colors.length];}async function pingDevice(device) {const startTime = Date.now();const target = device.hostName || device.ipAddress;try {// Simulate ping with timeout - agora com 95% de chance de falha para simular máquinas desligadasawait new Promise((resolve, reject) => {setTimeout(() => {if (Math.random() > 0.95) { // Apenas 5% de chance de sucesso para demoresolve();} else {reject(new Error('Request timed out - Device offline'));}}, 50 + Math.random() * 150); // Random response time between 50-200ms});const responseTime = Date.now() - startTime;// Update device statusdevice.status = 'online';device.lastPingTime = new Date().toLocaleString();device.responseTime = responseTime;device.checks++;device.onlineChecks++;// Record historyif (!pingHistory[target]) pingHistory[target] = [];pingHistory[target].push({time: new Date(),responseTime: responseTime,status: 'online'});return { success: true, responseTime };} catch (error) {// Update device statusdevice.status = 'offline';device.lastPingTime = new Date().toLocaleString();device.responseTime = 0;device.checks++;// Record historyif (!pingHistory[target]) pingHistory[target] = [];pingHistory[target].push({time: new Date(),responseTime: 0,status: 'offline'});return { success: false, error: error.message };}}async function pingAllDevices() {startPingBtn.innerHTML = '<i class="fas fa-sync-alt rotate mr-2"></i> Pinging...';startPingBtn.disabled = true;const pingPromises = devices.map(device => pingDevice(device));await Promise.all(pingPromises);renderDeviceTable();updateStats();updateTimelineChart();if (pingIntervalId) {startPingBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Pinging...';} else {startPingBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start Ping';startPingBtn.disabled = false;}}function startPing() {const interval = parseInt(pingIntervalInput.value) * 1000;if (isNaN(interval) || interval < 1000) {alert('Please enter a valid interval (at least 1 second)');return;}pingAllDevices(); // Run immediatelypingIntervalId = setInterval(pingAllDevices, interval);startPingBtn.disabled = true;stopPingBtn.disabled = false;}function stopPing() {if (pingIntervalId) {clearInterval(pingIntervalId);pingIntervalId = null;startPingBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start Ping';startPingBtn.disabled = false;stopPingBtn.disabled = true;}}// Initialize with some demo data for visualizationwindow.addEventListener('DOMContentLoaded', () => {// Add some sample data for the timeline chartconst now = new Date();const labels = Array.from({ length: 10 }, (_, i) => {const d = new Date(now);d.setMinutes(d.getMinutes() - (9 - i));return d.toLocaleTimeString();});timelineChart.data.labels = labels;timelineChart.update();});</script><p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=jair2323/cpm-igr" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body></html>
123Requisitos Funcionais Leitura de Excel Carregar um arquivo .xlsx com os campos: USER NAME | IGG | HOST NAME | IP ADDRESS | STATUS | LAST PING TIME Atualizar dinamicamente os campos STATUS e LAST PING TIME. Ping nos dispositivos Ping baseado em IP ADDRESS ou HOST NAME. Verificar disponibilidade (online/offline). Registrar o tempo da última resposta (timestamp + tempo de resposta em ms). Controles Botão Start Ping: Iniciar verificação contínua (intervalo configurável). Botão Stop Ping: Parar verificação. Possibilidade de definir intervalo de atualização (ex: a cada 5s). KPIs e Gráficos Uptime por dispositivo (em %). Tempo médio de resposta (ping). Gráfico interativo (ex: linha/área por dispositivo ao longo do tempo). Tabela de dispositivos com cor de status (verde = online, vermelho = offline)mude o leyout e a core para um cinza escuroas maquinas estao fisicamente off todas eleas mas na aplicação tenho maquinas online podes corrigirREADME.md+5-3
index.html+624-19
prompts.txtAdded+3