This change is forward-ported from SpectraBSD, which is stable/10. The changes were written by Ken Merry <ken@FreeBSD.org>.
Here are snippets from the original commit logs:
These statistics are similar to to what iostat(8) and ctlstat(8) report. In fact, some of the code has been borrowed from ctlstat and libdevstat. The statistics reported include kilobytes per transfer, transfers per second, megabytes per second, and I/O latency for reads, writes and all transactions. We also report the current queue length, and busy percentage. This is an improvement on the current NFS statistics, which are only operation counts. The better long term solution for this would be statistics collection at the VFS level, and integration with the devstat(9) subsystem so that we could have a common set of statistics routines that would work for disk-type devices and filesystems. nfsport.h: Add a start/done count, bytes transferred per operation, number of operations, operation duration, and busy time. nfs_nfsdport.c: Record bytes transferred. Note that this is not locked, which is a problem, and is not coincident with the entire operation getting recorded. nfs_nfsdsocket.c: Add two new routines, nfsrvd_statstart() and nfsrvd_statend(), that record statistics for each NFS operation type. Even though we have a provision to record bytes in nfsrvd_statend(), we don't because at this level, we haven't decoded enough of the request to know how long the operation is. nfsstat/Makefile: nfsstat now depends on libdevstat. nfsstat.1: Document the -d option to enable the new statistics reporting. nfsstat.c: Implement a new statistics reporting mode that is similar to what iostat(8) does. This mode is only active when -d and an interval is specified. Change exp_sideways() to print out the new statistics (when asked), and printhdr to print the new header. compute_new_stats() and compute_totals and the display code in exp_sideways() heavily borrow from ctlstat and borrow some from devstat. With higher NFS throughput, the existing -d dispay frequently wrapped past 80 columns due to the size of the MB/sec and tps numbers. To compensate for this, remove individual read and write latency from the default display for the -d option. (The total latency is still displayed by default.) Add a third stat type, STAT_TYPE_COMMIT. Read and write latency can now be added back in with the -W option. In addition, we now display commits per second and commit latency with the -d -W option. Make printhdr() look at the widemode flag when it is printing out the header for the newStats mode, and adjust the field headings to include or exclude fields depending on whether we are in wide mode. In exp_sidewaysintpr(), calculate commit latency and print it out in wide mode. Only print out read and write latency if we are in wide mode.