Simplify server stats for now
This commit is contained in:
@@ -82,36 +82,12 @@ export async function GET(request: Request) {
|
|||||||
return NextResponse.json(memories);
|
return NextResponse.json(memories);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SERVER STATUS - real data from docker
|
// SERVER STATUS - basic data only
|
||||||
if (type === 'server') {
|
if (type === 'server') {
|
||||||
try {
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
|
|
||||||
// Get container count
|
|
||||||
const containers = execSync('docker ps --format "{{.Names}}" | wc -l', { cwd: '/' }).toString().trim();
|
|
||||||
|
|
||||||
// Get disk usage
|
|
||||||
const disk = execSync('df -h / | tail -1 | awk \'{print $5}\'', { cwd: '/' }).toString().trim();
|
|
||||||
|
|
||||||
// Get RAM usage
|
|
||||||
const ram = execSync('free -h | grep Mem | awk \'{print $3 "/" $2}\'', { cwd: '/' }).toString().trim();
|
|
||||||
|
|
||||||
// Get load
|
|
||||||
const load = execSync('uptime | awk -F\'load average:\' \'{print $2}\'', { cwd: '/' }).toString().trim();
|
|
||||||
|
|
||||||
// Get uptime
|
|
||||||
const uptime = execSync('uptime', { cwd: '/' }).toString().trim();
|
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
containers: `${containers} running`,
|
status: 'ok',
|
||||||
disk: disk,
|
note: 'Full stats coming soon'
|
||||||
ram: ram,
|
|
||||||
load: load.trim(),
|
|
||||||
uptime: uptime
|
|
||||||
});
|
});
|
||||||
} catch (e: any) {
|
|
||||||
return NextResponse.json({ error: e.message }, { status: 500 });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BACKUP STATUS
|
// BACKUP STATUS
|
||||||
|
|||||||
Reference in New Issue
Block a user