feat(host_agent): NFS delay per mount, read from /proc/self/mountstats (#5996)
CI / lint (push) Successful in 2s
CI / unit (push) Failing after 1m32s
CI / integration (push) Successful in 1m31s
CI / publish (push) Skipped

Each sample carries each NFS mount's requests since the last one: how many
a second, their round trip and execute time (READ and WRITE on their own),
and how many were sent again or hit a major timeout. mountstats is the
kernel's own count and never touches the share, so it reads while one is
stuck. Steward stores them per mount and the slowest on the host as
nfs_exe_max_ms, for an "NFS slow" rule and the host page's NFS chart beside
mounts_stalled; each mount's bar says what a request took.

Agent 1.22.0 (which also carries the backlog order from 41fc807).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 09:46:14 -04:00
co-authored by Claude Opus 5.5
parent 2df8431de9
commit 3f9aae7f46
12 changed files with 282 additions and 13 deletions
@@ -181,3 +181,25 @@ def test_the_host_page_lists_filesystems_fullest_first():
"h:/data": {"disk_used_pct": 30.0}}
*_, mounts = _split_host_metrics("h", latest)
assert list(mounts) == ["/srv", "/var/lib/docker", "/", "/boot", "/data"]
def test_nfs_delay_is_recorded_per_mount_and_the_slowest_on_the_host():
"""#5996: what each NFS mount's requests took, and the host's slowest for a rule."""
sample = {"ts": "2026-10-17T12:00:00+00:00",
"nfs": [{"mount": "/nfs/data", "ops_per_sec": 4.0, "retrans": 2, "timeouts": 0,
"rtt_ms": 3.5, "exe_ms": 1250.0, "write_ms": 1400.0},
{"mount": "/nfs/media", "ops_per_sec": 1.0, "retrans": 0, "timeouts": 0,
"rtt_ms": 1.0, "exe_ms": 2.0, "read_ms": 2.0}]}
idx = _index(_expand_sample_to_metrics(sample, "d3", datetime.now(timezone.utc)))
assert idx[("nfs_exe_ms", "d3:/nfs/data")] == 1250.0
assert idx[("nfs_write_ms", "d3:/nfs/data")] == 1400.0 and ("nfs_read_ms", "d3:/nfs/data") not in idx
assert idx[("nfs_retrans", "d3:/nfs/data")] == 2 and idx[("nfs_ops_per_sec", "d3:/nfs/media")] == 1.0
assert idx[("nfs_exe_max_ms", "d3")] == 1250.0
def test_a_host_whose_nfs_mounts_finished_nothing_has_no_nfs_delay():
sample = {"ts": "2026-10-17T12:00:00+00:00",
"nfs": [{"mount": "/nfs/data", "ops_per_sec": 0.0, "retrans": 0, "timeouts": 0}]}
idx = _index(_expand_sample_to_metrics(sample, "d3", datetime.now(timezone.utc)))
assert idx[("nfs_ops_per_sec", "d3:/nfs/data")] == 0.0
assert ("nfs_exe_max_ms", "d3") not in idx and ("nfs_exe_ms", "d3:/nfs/data") not in idx