Skip to content

Fix I/O stats showing 0/0 on cgroup v2 hosts - #375

Open
void143 wants to merge 1 commit into
bcicen:masterfrom
void143:fix/io-stats-cgroup-v2
Open

Fix I/O stats showing 0/0 on cgroup v2 hosts#375
void143 wants to merge 1 commit into
bcicen:masterfrom
void143:fix/io-stats-cgroup-v2

Conversation

@void143

@void143 void143 commented Jun 11, 2026

Copy link
Copy Markdown

Problem

On cgroup v2 hosts, every container's IO column shows 0 / 0 regardless of actual disk activity, while docker stats reports correct Block I/O for the same containers.

Cause

The Docker stats API reports the blkio operation name differently between cgroup versions:

  • cgroup v1: "Read" / "Write" (capitalized)
  • cgroup v2: "read" / "write" (lowercase)

ReadIO in connector/collector/docker.go compared blk.Op with case-sensitive equality (== "Read" / == "Write"), so on cgroup v2 neither branch ever matches and the read/write totals stay at zero.

Raw API sample from a cgroup v2 host (io_service_bytes_recursive):

{ "major": 259, "minor": 0, "op": "read",  "value": 4096 }
{ "major": 259, "minor": 0, "op": "write", "value": 1781760 }

Fix

Compare the operation case-insensitively with strings.EqualFold, so the values populate correctly on both cgroup v1 and v2. No behavior change on cgroup v1.

Testing

Verified on a Docker 27.5.1 host with cgroup v2 (systemd driver). After the change, ctop's IO read/write match docker stats Block I/O for the same containers.

The Docker stats API reports the blkio operation as "Read"/"Write" under
cgroup v1 but lowercase "read"/"write" under cgroup v2. ReadIO compared
the op with a case-sensitive equality, so on cgroup v2 hosts neither branch
matched and every container reported 0/0 for IO read/write.

Compare the op case-insensitively with strings.EqualFold so the values are
populated correctly on both cgroup v1 and v2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant