Phillnet-2 / Tools /services /physicalPerceptionService.ts
ayjays132's picture
Upload 478 files
101858b verified
import os from 'node:os';
import process from 'node:process';
export class PhysicalPerceptionService {
async getStatus(): Promise<any> {
const uptimeSeconds = os.uptime();
const days = Math.floor(uptimeSeconds / (24 * 3600));
const hours = Math.floor((uptimeSeconds % (24 * 3600)) / 3600);
const minutes = Math.floor((uptimeSeconds % 3600) / 60);
return {
os: {
platform: os.platform(),
type: os.type(),
release: os.release(),
arch: os.arch(),
hostname: os.hostname(),
},
hardware: {
cpus: os.cpus().length,
totalMemory: `${(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
freeMemory: `${(os.freemem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
loadAverage: os.loadavg(),
},
process: {
pid: process.pid,
uptime: `${days}d ${hours}h ${minutes}m`,
cwd: process.cwd(),
execPath: process.execPath,
},
environment: {
nodeVersion: process.version,
timestamp: new Date().toISOString(),
}
};
}
}