Files
mcde/include/Mcde
lotherkandClaude Sonnet 5.5 6676102ec8 McdeSys: network and disk counters for the activity window (t0091, McdeSys part 2)
mcde_sys_net_io: bytes and packets each way, for each interface (the loopback
too).  mcde_sys_disk_io: bytes and operations read and written, for each whole
disk (no partitions; no loop, ram or zram devices).  The difference of two
readings over the seconds between them is the rate the Network and Disk
Activity tabs draw.

NetBSD (read in the tree first): the interface counters are the struct if_data
of the link-level address from getifaddrs(3) (ifi_ibytes, ifi_obytes,
ifi_ipackets, ifi_opackets); the disks come from sysctl hw.iostats
{CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl)}, asked for its size and then for
the array (usr.bin/vmstat/drvstats.c:183-188, :323-328), type IOSTAT_DISK,
rbytes/wbytes/rxfer/wxfer (sys/sys/iostat.h).  Cross-compiled with
x86_64--netbsd-gcc -Wall -Wextra: no diagnostic.  NEVER RUN on NetBSD.
Linux: /proc/net/dev (64-bit counters), /proc/diskstats (512-byte sectors),
whole disks only: those with a directory in /sys/block.

test_sysload (make check, 7 of 7) now also: 2 MB sent over a TCP connection on
127.0.0.1 raise the loopback's rx and tx bytes by at least 2,000,000 and its
packets; 8 MB written and fsync'ed next to the test move the disks' write
counters (measured here: 25,595,904 bytes for 8 MB -- the device-mapper volume
and the physical disk under it are both whole devices, so a window should not
add them up); the counters never go back by name; the write check says SKIP
instead of failing where the file system has no disk.  Mutants: rx bytes taken
from packets fails 2 checks, write bytes taken from the read sectors fails 1,
sectors not multiplied by 512 fails 1.

Not done of t0091: the program (programs/dtactivity).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 05:03:08 +00:00
..