const si = require("systeminformation"); const { directorySize } = require("../utils/fs"); const { paths } = require("../config/paths"); const { listJobs } = require("../queue/jobs"); async function snapshot() { const [cpu, mem, fsSize, tempSize, cacheSize] = await Promise.all([ si.currentLoad(), si.mem(), si.fsSize(), directorySize(paths.temp), directorySize(paths.cache) ]); const jobs = listJobs(200); return { time: new Date().toISOString(), cpu: { load: cpu.currentLoad }, memory: { total: mem.total, used: mem.used, free: mem.free }, disks: fsSize, storage: { tempSize, cacheSize }, jobs: { total: jobs.length, active: jobs.filter((job) => ["downloading", "validating", "probing", "planning", "splitting", "compressing", "uploading"].includes(job.status)).length, failed: jobs.filter((job) => job.status === "failed").length, completed: jobs.filter((job) => job.status === "completed").length, queued: jobs.filter((job) => ["queued", "retrying"].includes(job.status)).length } }; } module.exports = { snapshot };