Parse a cgroup value file: numeric bytes, or null for absent/'max'.
(path: string)
| 26 | |
| 27 | /** Parse a cgroup value file: numeric bytes, or null for absent/'max'. */ |
| 28 | function readCgroupBytes(path: string): number | null { |
| 29 | try { |
| 30 | const raw = fs.readFileSync(path, 'utf8').trim(); |
| 31 | if (raw === 'max') return null; |
| 32 | const n = Number.parseInt(raw, 10); |
| 33 | return Number.isFinite(n) && n >= 0 ? n : null; |
| 34 | } catch { |
| 35 | return null; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /** `inactive_file` from a cgroup memory.stat file — reclaimable page cache. */ |
| 40 | function readInactiveFile(statPath: string): number { |
no outgoing calls
no test coverage detected