asomers / ztop

Display ZFS datasets' I/O in real time
BSD 2-Clause "Simplified" License
69 stars 7 forks source link

initial linux implementation #26

Closed penryu closed 1 year ago

penryu commented 1 year ago

First run at adding linux support for ztop using procfs with nodes at /proc/spl/kstat/zfs/.../.

Adds glob crate as dependency.

Potentially closes #9.

penryu commented 1 year ago

Per a request in #13, here is the contents of the zfs branch of procfs on the system used to develop this PR:

/proc/spl/kstat/zfs/fm
/proc/spl/kstat/zfs/zil
/proc/spl/kstat/zfs/zstd
/proc/spl/kstat/zfs/bpool/txgs
/proc/spl/kstat/zfs/bpool/reads
/proc/spl/kstat/zfs/bpool/state
/proc/spl/kstat/zfs/bpool/iostats
/proc/spl/kstat/zfs/bpool/multihost
/proc/spl/kstat/zfs/bpool/objset-0x8d
/proc/spl/kstat/zfs/bpool/dmu_tx_assign
/proc/spl/kstat/zfs/dbufs
/proc/spl/kstat/zfs/rpool/txgs
/proc/spl/kstat/zfs/rpool/reads
/proc/spl/kstat/zfs/rpool/state
/proc/spl/kstat/zfs/rpool/iostats
/proc/spl/kstat/zfs/rpool/multihost
/proc/spl/kstat/zfs/rpool/objset-0x44
/proc/spl/kstat/zfs/rpool/objset-0x4b
/proc/spl/kstat/zfs/rpool/objset-0xe8
/proc/spl/kstat/zfs/rpool/objset-0x110
/proc/spl/kstat/zfs/rpool/objset-0x117
/proc/spl/kstat/zfs/rpool/objset-0x204
/proc/spl/kstat/zfs/rpool/objset-0x20c
/proc/spl/kstat/zfs/rpool/objset-0x213
/proc/spl/kstat/zfs/rpool/objset-0x21a
/proc/spl/kstat/zfs/rpool/objset-0x221
/proc/spl/kstat/zfs/rpool/objset-0x285
/proc/spl/kstat/zfs/rpool/objset-0x303
/proc/spl/kstat/zfs/rpool/objset-0x30a
/proc/spl/kstat/zfs/rpool/objset-0x311
/proc/spl/kstat/zfs/rpool/objset-0x384
/proc/spl/kstat/zfs/rpool/objset-0x6b0
/proc/spl/kstat/zfs/rpool/dmu_tx_assign
/proc/spl/kstat/zfs/dbgmsg
/proc/spl/kstat/zfs/dmu_tx
/proc/spl/kstat/zfs/abdstats
/proc/spl/kstat/zfs/arcstats
/proc/spl/kstat/zfs/dbufstats
/proc/spl/kstat/zfs/dnodestats
/proc/spl/kstat/zfs/zfetchstats
/proc/spl/kstat/zfs/metaslab_stats
/proc/spl/kstat/zfs/import_progress
/proc/spl/kstat/zfs/fletcher_4_bench
/proc/spl/kstat/zfs/vdev_cache_stats
/proc/spl/kstat/zfs/vdev_raidz_bench
/proc/spl/kstat/zfs/vdev_mirror_stats

Sample contents of one of the objset-* "files" is included as a test case.

And sample ztop output:

   r/s   kB/s r     w/s   kB/s w     d/s  kB/s d  Dataset
     0        0       0        0       0       0  bpool/BOOT/ubuntu_lta4aS
    32       17       1        0       1       0  rpool/ROOT/ubuntu_lta4aS
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/srv
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/usr/local
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/games
     3        4       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/lib
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/lib/AccountsService
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/lib/NetworkManager
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/lib/apt
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/lib/dpkg
     1        3       3        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/log
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/mail
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/snap
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/spool
     0        0       0        0       0       0  rpool/ROOT/ubuntu_lta4aS/var/www
     4        2       0        0       1       0  rpool/USERDATA/chuckles_1p41bf
     0        0       0        0       0       0  rpool/USERDATA/root_1p41bf
penryu commented 1 year ago

wrt check failure in FBSD13, it seems unrelated to my changes, but am happy to look at the failure more closely if requested.

UPDATE: This branch builds, tests, and runs successfully under FreeBSD-13 (both nightly and stable) for me.

asomers commented 1 year ago

The CI errors are caused by your addition of a .rustfmt.toml file, even though rustfmt.toml already exists. You should remove the new file.

penryu commented 1 year ago

D'oh. I've removed the file.

Please let me know if you have any questions or concerns about the patch. I'm happy to answer!

penryu commented 1 year ago

Okay, I've not contributed many patches via GitHub before, and just noticed the threads for https://github.com/asomers/ztop/issues/9 and https://github.com/asomers/ztop/pull/13 . Apologies! I'm not trying to step on any toes.

Essentially I'd just like to use this on the ZoL systems at my work, so whatever the simplest/best path is fine by me.

asomers commented 1 year ago

BTW I'm on vacation right now, but I'll review this next week.

penryu commented 1 year ago

Absolutely! Just let me know what it needs and I'll make sure to get it in!

penryu commented 1 year ago

@asomers Does this PR need more work? I'm happy to put more/different work in if it helps add Linux support to the great tool you've built.

penryu commented 1 year ago

@asomers Have you had any time to review the Linux changes?

asomers commented 1 year ago

@penryu since I was so tardy on reviewing this, I went ahead and applied my suggestions myself. Does it look good to you? If you don't respond I'll merge and release in a week or so. Thanks for your contribution!

asomers commented 1 year ago

BTW, I just published v0.2.2 with Linux support.