diff --git a/posimai-dev/server.js b/posimai-dev/server.js index 69579916..3fb3d427 100644 --- a/posimai-dev/server.js +++ b/posimai-dev/server.js @@ -7,6 +7,7 @@ const https = require('https'); const fs = require('fs'); const path = require('path'); const os = require('os'); +const { execSync } = require('child_process'); const app = express(); const PORT = process.env.PORT || 3333; @@ -63,13 +64,34 @@ app.get('/api/health', (req, res) => { return sum + (dTotal > 0 ? (1 - dIdle / dTotal) * 100 : 0); }, 0) / s1.length; + // Disk usage + let disk = null; + try { + const dfOut = execSync('df -B1 / 2>/dev/null', { timeout: 2000 }).toString(); + const parts = dfOut.trim().split('\n')[1].split(/\s+/); + const totalB = parseInt(parts[1]); + const usedB = parseInt(parts[2]); + disk = { + total_gb: Math.round(totalB / 1e9 * 10) / 10, + used_gb: Math.round(usedB / 1e9 * 10) / 10, + use_pct: Math.round(usedB / totalB * 100), + }; + } catch (_) {} + + // Load average (1 / 5 / 15 min) and CPU count + const loadAvg = os.loadavg(); + const cpuCount = os.cpus().length; + res.json({ ok: true, hostname: os.hostname(), uptime_s: Math.floor(os.uptime()), cpu_pct: Math.round(cpuPct), + cpu_count: cpuCount, + load_avg: loadAvg.map(l => Math.round(l * 100) / 100), mem_used_mb: Math.round((total - mem) / 1024 / 1024), mem_total_mb: Math.round(total / 1024 / 1024), + disk, active_sessions: wss.clients ? wss.clients.size : 0, node_version: process.version, platform: os.platform(), diff --git a/posimai-dev/station.html b/posimai-dev/station.html index 5e68fd57..925f51fe 100644 --- a/posimai-dev/station.html +++ b/posimai-dev/station.html @@ -9,7 +9,7 @@ - +
@@ -371,35 +395,37 @@