Add system monitoring with real-time metrics to admin dashboard
All checks were successful
Build And Push Image / docker (push) Successful in 2m54s
All checks were successful
Build And Push Image / docker (push) Successful in 2m54s
- Add systeminformation package for system metrics collection - Create system-metrics utility for CPU, memory, disk monitoring - Update admin stats API to return real system health data - Replace mock data with live system metrics in admin dashboard - Update @vite-pwa/nuxt to v0.10.8
This commit is contained in:
@@ -17,15 +17,38 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
console.log('✅ Admin access verified for user:', session.user.email);
|
||||
|
||||
// For now, return improved mock data - TODO: integrate with real data sources
|
||||
// Get real system metrics
|
||||
const { getSystemMetrics, getSystemHealthStatus, formatBytes } = await import('~/server/utils/system-metrics');
|
||||
const systemMetrics = await getSystemMetrics();
|
||||
const systemHealth = getSystemHealthStatus(systemMetrics);
|
||||
|
||||
// Build comprehensive stats with real data
|
||||
const stats = {
|
||||
// Real system metrics
|
||||
totalUsers: 156, // TODO: Get from Keycloak API
|
||||
activeUsers: 45, // TODO: Get from session store
|
||||
activeUsers: 45, // TODO: Get from session store
|
||||
totalSessions: 67, // TODO: Get from session store
|
||||
systemHealth: 'healthy',
|
||||
systemHealth,
|
||||
lastBackup: new Date().toISOString(),
|
||||
diskUsage: '45%',
|
||||
memoryUsage: '62%',
|
||||
diskUsage: `${systemMetrics.disk.usagePercent}%`,
|
||||
memoryUsage: `${systemMetrics.memory.usagePercent}%`,
|
||||
|
||||
// Enhanced system metrics with real data
|
||||
systemMetrics: {
|
||||
cpu: systemMetrics.cpu.usage,
|
||||
memory: systemMetrics.memory.usagePercent,
|
||||
disk: systemMetrics.disk.usagePercent,
|
||||
uptime: systemMetrics.uptime,
|
||||
processes: systemMetrics.processes.total,
|
||||
cpuCores: systemMetrics.cpu.cores,
|
||||
cpuModel: systemMetrics.cpu.model,
|
||||
memoryTotal: formatBytes(systemMetrics.memory.total),
|
||||
memoryUsed: formatBytes(systemMetrics.memory.used),
|
||||
diskTotal: formatBytes(systemMetrics.disk.total),
|
||||
diskUsed: formatBytes(systemMetrics.disk.used)
|
||||
},
|
||||
|
||||
// Mock data for features not yet implemented
|
||||
recentActivity: [
|
||||
{
|
||||
action: 'User login',
|
||||
@@ -46,12 +69,7 @@ export default defineEventHandler(async (event) => {
|
||||
type: 'success'
|
||||
}
|
||||
],
|
||||
systemMetrics: {
|
||||
cpu: 45,
|
||||
memory: 62,
|
||||
disk: 38,
|
||||
uptime: '5d 12h 30m'
|
||||
},
|
||||
|
||||
securityAlerts: [
|
||||
{
|
||||
id: 1,
|
||||
@@ -70,7 +88,7 @@ export default defineEventHandler(async (event) => {
|
||||
]
|
||||
};
|
||||
|
||||
console.log('✅ Admin stats retrieved successfully');
|
||||
console.log('✅ Admin stats retrieved successfully with real system metrics');
|
||||
return stats;
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user