Download dev/tests/web/parse_dump.cpp from mchuca/ServerMonitor: direct link, hf CLI and curl.
- Browser
- Download file 3 kB
-
https://huggingface.co/mchuca/ServerMonitor/resolve/main/dev/tests/web/parse_dump.cpp
- Command line
-
hf download hf://mchuca/ServerMonitor/dev/tests/web/parse_dump.cpp
-
curl -L -o parse_dump.cpp https://huggingface.co/mchuca/ServerMonitor/resolve/main/dev/tests/web/parse_dump.cpp
3 kB
| // Feeds captured collector frames to the C++ reference parser and prints every value (for comparison with the JS parser). | |
| static void d(const char *k, double v) { printf("%s=%.4f\n", k, v); } | |
| int main(int, char **argv) { | |
| QFile f(argv[1]); f.open(QIODevice::ReadOnly); | |
| QByteArray buf = f.readAll(); | |
| MetricsEngine e; Metrics m; int n = 0; | |
| for (int end; (end = buf.indexOf("@@SNAP_END")) >= 0;) { | |
| const int begin = buf.lastIndexOf("@@SNAP_BEGIN", end); | |
| if (begin >= 0) m = e.process(buf.mid(begin, end - begin), 1000 + n++); | |
| buf.remove(0, end + 10); | |
| } | |
| printf("frames=%d valid=%d host=%s os=%s kernel=%s arch=%s cpu=%s virt=%s fullest=%s busiest=%s\n", n, m.valid, qPrintable(m.hostname), qPrintable(m.os), qPrintable(m.kernel), qPrintable(m.arch), qPrintable(m.cpuModel), qPrintable(m.virt), qPrintable(m.fullestMount), qPrintable(m.busiestDisk)); | |
| D(cpuCount) D(loggedUsers) D(procsRunning) D(procsBlocked) D(threadsTotal) D(socketsUsed) D(servicesFailed) D(servicesRunning) D(uptime) D(load1) D(load5) D(load15) | |
| D(cpuUsage) D(cpuUser) D(cpuSystem) D(cpuIowait) D(cpuSteal) D(cpuIrq) D(ctxtPerSec) D(intrPerSec) D(forksPerSec) D(avgMhz) D(memTotal) D(memFree) D(memAvailable) D(memUsed) D(buffers) D(cached) | |
| D(shared) D(slab) D(dirty) D(swapTotal) D(swapUsed) D(memPct) D(swapPct) D(diskReadBps) D(diskWriteBps) D(maxDiskPct) D(maxDiskUtil) D(netRxBps) D(netTxBps) D(maxTemp) | |
| for (const auto &c : m.cores) printf("core %.4f %.4f\n", c.usage, c.mhz); | |
| for (const auto &x : m.mounts) printf("mount %s|%s|%s %.0f %.0f %.0f %.4f\n", qPrintable(x.device), qPrintable(x.type), qPrintable(x.mount), x.total, x.used, x.avail, x.pct); | |
| for (const auto &x : m.disks) printf("disk %s %.4f %.4f %.4f %.4f %.4f %.0f %.0f\n", qPrintable(x.name), x.readBps, x.writeBps, x.readIops, x.writeIops, x.util, x.totalRead, x.totalWritten); | |
| for (const auto &x : m.nets) printf("net %s %s %d %d %.4f %.4f %.4f %.4f %.0f %.0f %.0f %.0f\n", qPrintable(x.name), qPrintable(x.state), x.speed, x.virt, x.rxBps, x.txBps, x.rxPps, x.txPps, x.rxBytes, x.txBytes, x.errors, x.drops); | |
| for (auto it = m.tcp.cbegin(); it != m.tcp.cend(); ++it) printf("tcp %s %d\n", qPrintable(it.key()), it.value()); | |
| for (const auto &p : m.procs) printf("proc %d %d %d %d %s|%s|%c %.4f %.4f %.0f %.0f %.2f\n", p.pid, p.ppid, p.threads, p.nice, qPrintable(p.name), qPrintable(p.user), p.state.toLatin1(), p.cpu, p.memPct, p.rss, p.vsz, p.age); | |
| for (const auto &s : m.services) printf("svc %s|%s|%s|%s|%s\n", qPrintable(s.unit), qPrintable(s.load), qPrintable(s.active), qPrintable(s.sub), qPrintable(s.description)); | |
| for (const auto &t : m.temps) printf("temp %s %.4f\n", qPrintable(t.name), t.celsius); | |
| for (const auto &g : m.gpus) printf("gpu %d %s %.2f %.2f %.2f %.2f %.2f %.2f\n", g.index, qPrintable(g.name), g.util, g.memUsed, g.memTotal, g.temp, g.power, g.fan); | |
| } | |