UNPKG

@5app/health-check-helpers

Version:
28 lines (23 loc) 606 B
import os from 'node:os'; function toMegabytes(bytes) { const megabytes = Number(bytes / (1024 * 1024)).toFixed(3); return `${megabytes} MB`; } function uptimeAsDate(seconds) { return new Date(Date.now() - seconds * 1000); } export default function processMetadata() { return { platform: { type: os.platform(), freeMemory: toMegabytes(os.freemem()), totalMemory: toMegabytes(os.totalmem()), startedOn: uptimeAsDate(os.uptime()), }, process: { pid: process.pid, cpuUsage: process.cpuUsage(), // Values in microseconds startedOn: uptimeAsDate(process.uptime()), }, }; }