diff options
Diffstat (limited to 'desktop/modules')
| -rw-r--r-- | desktop/modules/perf/Perf.js | 11 | ||||
| -rw-r--r-- | desktop/modules/perf/test_perf.js | 6 |
2 files changed, 13 insertions, 4 deletions
diff --git a/desktop/modules/perf/Perf.js b/desktop/modules/perf/Perf.js index d067d3b..eb0dbd7 100644 --- a/desktop/modules/perf/Perf.js +++ b/desktop/modules/perf/Perf.js @@ -186,16 +186,21 @@ function procs(text) { // One {key, name, rx, tx} per TCP socket in `ss -tinpH` output: a line // naming the owner in users:((...)), then the -i line under it with the // byte counters. Sockets ss names no owner for (other users', without root) -// are skipped. The key is both endpoints and the pid, so a reused port in -// another process is a new socket. +// are skipped, except NFS: the kernel's client owns that socket, so a file +// manager copying to or from a share shows nothing of its own, and the +// traffic is listed as "NFS <server>" instead. The key is both endpoints and +// the pid, so a reused port in another process is a new socket. function sockets(text) { const out = []; let cur = null; for (const line of text.split("\n")) { - const u = /^\S+\s+\d+\s+\d+\s+(\S+)\s+(\S+)\s+users:\(\("([^"]*)",pid=(\d+)/.exec(line); + let u = /^\S+\s+\d+\s+\d+\s+(\S+)\s+(\S+)\s+users:\(\("([^"]*)",pid=(\d+)/.exec(line); if (u) { cur = { key: u[1] + " " + u[2] + " " + u[4], name: u[3], rx: 0, tx: 0 }; out.push(cur); + } else if ((u = /^\S+\s+\d+\s+\d+\s+(\S+)\s+(\S+):2049\s*$/.exec(line))) { + cur = { key: u[1] + " " + u[2] + ":2049", name: "NFS " + u[2], rx: 0, tx: 0 }; + out.push(cur); } else if (cur && /^\s/.test(line)) { cur.rx = Number((/bytes_received:(\d+)/.exec(line) || [0, 0])[1]); cur.tx = Number((/bytes_sent:(\d+)/.exec(line) || [0, 0])[1]); diff --git a/desktop/modules/perf/test_perf.js b/desktop/modules/perf/test_perf.js index 7c108a8..d5856e8 100644 --- a/desktop/modules/perf/test_perf.js +++ b/desktop/modules/perf/test_perf.js @@ -153,7 +153,8 @@ assert.deepStrictEqual(P.procs(frame), [ ]); assert.deepStrictEqual(P.procs(""), []); -// sockets: owned sockets with their -i counters; ownerless ones skipped. +// sockets: owned sockets with their -i counters; ownerless ones skipped +// unless they are the kernel's NFS client. const ss = [ "ESTAB 0 0 10.0.0.5:35806 192.0.2.1:443 users:((\"firefox\",pid=12,fd=53))", "\t cubic rto:340 bytes_sent:100 bytes_acked:101 bytes_received:5000 segs_out:2", @@ -161,11 +162,14 @@ const ss = [ "\t cubic bytes_sent:999 bytes_received:999", "SYN-SENT 0 1 10.0.0.5:49916 192.0.2.2:65081 users:((\"ktorrent\",pid=7,fd=67))", "\t cubic rto:1000 segs_out:3", + "ESTAB 0 0 10.0.0.5:678 192.0.2.4:2049", + "\t cubic bytes_sent:7 bytes_received:8000", ].join("\n"); const socks = P.sockets(ss); assert.deepStrictEqual(socks, [ { key: "10.0.0.5:35806 192.0.2.1:443 12", name: "firefox", rx: 5000, tx: 100 }, { key: "10.0.0.5:49916 192.0.2.2:65081 7", name: "ktorrent", rx: 0, tx: 0 }, + { key: "10.0.0.5:678 192.0.2.4:2049", name: "NFS 192.0.2.4", rx: 8000, tx: 7 }, ]); // netProcs: deltas over the interval summed by name; a new socket counts |
