Download dev/tests/web/parse_dump.js from mchuca/ServerMonitor: direct link, hf CLI and curl.
- Browser
- Download file 2.42 kB
-
https://huggingface.co/mchuca/ServerMonitor/resolve/main/dev/tests/web/parse_dump.js
- Command line
-
hf download hf://mchuca/ServerMonitor/dev/tests/web/parse_dump.js
-
curl -L -o parse_dump.js https://huggingface.co/mchuca/ServerMonitor/resolve/main/dev/tests/web/parse_dump.js
2.42 kB
| // same dump as parse_dump.cpp from the JS parser: node parse_dump.js <project root> <frames file> | |
| const fs = require('fs'), path = require('path'), plat = require(path.join(process.argv[2], 'core/platform.js')); | |
| let buf = fs.readFileSync(process.argv[3], 'utf8'), m, n = 0; | |
| const st = {}, out = [], f = (v, p = 4) => (+v).toFixed(p), line = s => out.push(s); | |
| for (let end; (end = buf.indexOf('@@SNAP_END')) >= 0; buf = buf.slice(end + 10)) { const begin = buf.lastIndexOf('@@SNAP_BEGIN', end); if (begin >= 0) m = plat.parse(buf.slice(begin, end), st, 1000 + n++); } | |
| line(`frames=${n} valid=${+m.valid} host=${m.hostname} os=${m.os} kernel=${m.kernel} arch=${m.arch} cpu=${m.cpuModel} virt=${m.virt} fullest=${m.fullestMount} busiest=${m.busiestDisk}`); | |
| for (const k of ('cpuCount loggedUsers procsRunning procsBlocked threadsTotal socketsUsed servicesFailed servicesRunning uptime load1 load5 load15 cpuUsage cpuUser cpuSystem cpuIowait cpuSteal cpuIrq ctxtPerSec intrPerSec forksPerSec avgMhz memTotal memFree memAvailable memUsed buffers cached ' + | |
| 'shared slab dirty swapTotal swapUsed memPct swapPct diskReadBps diskWriteBps maxDiskPct maxDiskUtil netRxBps netTxBps maxTemp').split(' ')) line(`${k}=${f(m[k])}`); | |
| for (const c of m.cores) line(`core ${f(c.usage)} ${f(c.mhz)}`); | |
| for (const x of m.mounts) line(`mount ${x.device}|${x.type}|${x.mount} ${f(x.total, 0)} ${f(x.used, 0)} ${f(x.avail, 0)} ${f(x.pct)}`); | |
| for (const x of m.disks) line(`disk ${x.name} ${f(x.readBps)} ${f(x.writeBps)} ${f(x.readIops)} ${f(x.writeIops)} ${f(x.util)} ${f(x.totalRead, 0)} ${f(x.totalWritten, 0)}`); | |
| for (const x of m.nets) line(`net ${x.name} ${x.state} ${x.speed} ${+x.virt} ${f(x.rxBps)} ${f(x.txBps)} ${f(x.rxPps)} ${f(x.txPps)} ${f(x.rxBytes, 0)} ${f(x.txBytes, 0)} ${f(x.errors, 0)} ${f(x.drops, 0)}`); | |
| for (const k of Object.keys(m.tcp).sort()) line(`tcp ${k} ${m.tcp[k]}`); | |
| for (const p of m.procs) line(`proc ${p.pid} ${p.ppid} ${p.threads} ${p.nice} ${p.name}|${p.user}|${p.state} ${f(p.cpu)} ${f(p.memPct)} ${f(p.rss, 0)} ${f(p.vsz, 0)} ${f(p.age, 2)}`); | |
| for (const s of m.services) line(`svc ${s.unit}|${s.load}|${s.active}|${s.sub}|${s.description}`); | |
| for (const t of m.temps) line(`temp ${t.name} ${f(t.celsius)}`); | |
| for (const g of m.gpus) line(`gpu ${g.index} ${g.name} ${f(g.util, 2)} ${f(g.memUsed, 2)} ${f(g.memTotal, 2)} ${f(g.temp, 2)} ${f(g.power, 2)} ${f(g.fan, 2)}`); | |
| console.log(out.join('\n')); | |