Completely Fake Blog

Welcome to my blog

zpool iostat pront headers each time terminal fills

For a very long time I wanted to become part of actively programming OpenZFS community. This year finally I gathered courage and attacked very simple ZFS on Linux issue that proved to be perfect for me.
8235: feature request: zpool iostat N should repeat header like vmstat N. Not much changes, about 20 lines of code and few very small additions to man page, but I really like the outcome: pull request 8262. It's already merged.

The change itself isn't big. All version of zpool iostat N (where N is a number) will print statistics every N seconds (you can use parts of seconds, like 0.25 will be every 1/4th of a second). Versions before my change will print headers only once, at the start, requiring command user to remember column layout and their meaning. Some other commands, however, like vmstat, check for terminal height and each time headers are pushed out of the visible rows, they are printed again. This is a small but nice feature. In two scenarios zpool iostat N will work as previously - with newly introduced -n flag and when output is redirected from stdout. Both are there to help with scripts that rely on parsing zpool iostat N output.

The code itself isn't something to dwell into. Total line increase in zpool_main.c is 34 lines and the diff is available here. The change contains added functionality to zpool_main.c and to man 8 zpool page.