MCPcopy
hub / github.com/browserless/browserless / HostSource

Class HostSource

src/monitoring.ts:63–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63export class HostSource implements MachineStatsSource {
64 public readonly name = 'host (systeminformation)';
65 protected log = new Logger('hardware');
66
67 public async read(): Promise<IResourceLoad> {
68 const [cpuLoad, memLoad] = await Promise.all([
69 si.currentLoad(),
70 si.mem(),
71 ]).catch((err) => {
72 this.log.error(`Error checking machine stats`, err);
73 return [null, null];
74 });
75
76 const cpu = cpuLoad ? cpuLoad.currentLoadUser / 100 : null;
77 const memory = memLoad ? memLoad.active / memLoad.total : null;
78
79 return { cpu, memory };
80 }
81}
82
83type Sample = { usageUsec: number; timestamp: number };
84

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected