| 61 | } |
| 62 | |
| 63 | export 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 | |
| 83 | type Sample = { usageUsec: number; timestamp: number }; |
| 84 |
nothing calls this directly
no outgoing calls
no test coverage detected