mmatuska / zfs-stats

ZFS statistics tool
http://www.vx.sk/zfs-stats
63 stars 19 forks source link

Use of uninitialized value(s) under FreeBSD 14.1 #10

Open ozgurkazancci opened 2 months ago

ozgurkazancci commented 2 months ago

zfs-stats -a under FreeBSD 14.1 gives several warning/issue reports:

Use of uninitialized value $kdata in multiplication (*) at /usr/local/bin/zfs-stats line 329. Use of uninitialized value $vdev_cache_hits in addition (+) at /usr/local/bin/zfs-stats line 628. Use of uninitialized value $vdev_cache_misses in addition (+) at /usr/local/bin/zfs-stats line 628. Use of uninitialized value $vdev_cache_delegations in addition (+) at /usr/local/bin/zfs-stats line 628. Use of uninitialized value in numeric eq (==) at /usr/local/bin/zfs-stats line 630.

zfs-stats version 1.3.2

Regards.

shegnauer commented 1 month ago

correction for line 329 error:

--- /original/zfs-stats       2023-05-19 11:19:45.000000000 +0200
+++ /usr/local/bin/zfs-stats    2024-07-19 09:56:40.768547000 +0200
@@ -323,10 +323,9 @@
        my $ktext;
        $ktext += $_ for @ktext; # add the elements of size up

-       my @kdata = map { /([0-9]+)K/ } run('vmstat_m'); # retrieve the MemUse column
+       my @kdata = map { /([0-9]+)/ && (split)[3] } run('vmstat_m'); # retrieve the MemUse column
        my $kdata;
        $kdata += $_ for @kdata; # add the elements of MemUse up
-       $kdata *= 1024; # convert from KiB to Bytes

        my $kmem = ($ktext + $kdata);
        my $kmem_map_size = $Kstat->{"vm.kmem_map_size"};

lines 628-630: in my case I have vdev cache switched off, therefore the sysctl oid's are missing. For me the easy solution is NOT to use -D when calling zfs-stats. Note that -D is included in -a. In my case zfs-stats -IMAELZ works for me.