Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Feb 2021 14:30:45 +0000 (UTC)
From:      =?UTF-8?Q?Stefan_E=c3=9fer?= <se@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r566605 - in head/sysutils/zfs-stats: . files
Message-ID:  <202102261430.11QEUj8R013502@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: se
Date: Fri Feb 26 14:30:45 2021
New Revision: 566605
URL: https://svnweb.freebsd.org/changeset/ports/566605

Log:
  Fix printing of non-numeric sysctl variables
  
  In OpenZFS there are several new sysctl variables with non-numeric values
  that caused warning messages when trying to print them with a "%d" format.
  
  Fix this by detecting non-numeric values and printing them with "%s".
  
  Reported by:	David Schlachter

Modified:
  head/sysutils/zfs-stats/Makefile
  head/sysutils/zfs-stats/files/patch-zfs-stats

Modified: head/sysutils/zfs-stats/Makefile
==============================================================================
--- head/sysutils/zfs-stats/Makefile	Fri Feb 26 13:56:32 2021	(r566604)
+++ head/sysutils/zfs-stats/Makefile	Fri Feb 26 14:30:45 2021	(r566605)
@@ -3,7 +3,7 @@
 
 PORTNAME=	zfs-stats
 PORTVERSION=	1.3.0
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	sysutils
 MASTER_SITES=	GH
 

Modified: head/sysutils/zfs-stats/files/patch-zfs-stats
==============================================================================
--- head/sysutils/zfs-stats/files/patch-zfs-stats	Fri Feb 26 13:56:32 2021	(r566604)
+++ head/sysutils/zfs-stats/files/patch-zfs-stats	Fri Feb 26 14:30:45 2021	(r566605)
@@ -1,4 +1,4 @@
---- zfs-stats.orig	2020-12-17 11:05:01 UTC
+--- zfs-stats.orig	2021-02-26 14:24:06 UTC
 +++ zfs-stats
 @@ -1,4 +1,4 @@
 -#!/usr/local/bin/perl
@@ -6,8 +6,12 @@
  #
  # $Id$
  #
-@@ -46,7 +46,7 @@ use warnings;
+@@ -44,9 +44,11 @@
+ use strict;
+ use warnings;
  use Getopt::Long;
++use Scalar::Util qw(looks_like_number);
++
  Getopt::Long::Configure ("bundling");
  
 -my $version = '1.3.0';
@@ -15,7 +19,7 @@
  
  my $usetunable = 1;			# Change to 0 to disable sysctl MIB spill.
  my $show_sysctl_descriptions = 0;	# Change to 1 (or use the -d flag) to show sysctl descriptions.
-@@ -98,6 +98,7 @@ Usage: $0 [-ABDHLMSabdhus]
+@@ -98,6 +100,7 @@ Usage: $0 [-ABDHLMSabdhus]
  -E	: ARC efficiency
  -D	: VDEV cache statistics
  -L	: L2 ARC statistics
@@ -23,7 +27,7 @@
  -Z	: DMU (zfetch) statistics
  
  -R	: display raw numbers and bytes
-@@ -201,6 +202,14 @@ sub fPerc {
+@@ -201,6 +204,14 @@ sub fPerc {
  	} else { return sprintf('%0.' . $Decimal . 'f', 100) . "%"; }
  }
  
@@ -38,7 +42,7 @@
  my @Kstats = qw(
  	hw.machine
  	hw.machine_arch
-@@ -215,12 +224,28 @@ my @Kstats = qw(
+@@ -215,12 +226,28 @@ my @Kstats = qw(
  	vm.kmem_size_min
  	vm.kmem_size_scale
  	vm.stats
@@ -68,7 +72,7 @@
  	div1;
  	printf("ZFS Subsystem Report\t\t\t\t%s", $daydate);
  	div2;
-@@ -330,17 +355,16 @@ sub _arc_summary {
+@@ -330,17 +357,16 @@ sub _arc_summary {
  	my $deleted = $Kstat->{"kstat.zfs.misc.arcstats.deleted"};
  	my $evict_skip = $Kstat->{"kstat.zfs.misc.arcstats.evict_skip"};
  	my $mutex_miss = $Kstat->{"kstat.zfs.misc.arcstats.mutex_miss"};
@@ -87,7 +91,7 @@
  	my $mru_size = $Kstat->{"kstat.zfs.misc.arcstats.p"};
  	my $target_max_size = $Kstat->{"kstat.zfs.misc.arcstats.c_max"};
  	my $target_min_size = $Kstat->{"kstat.zfs.misc.arcstats.c_min"};
-@@ -356,7 +380,12 @@ sub _arc_summary {
+@@ -356,7 +382,12 @@ sub _arc_summary {
  		fPerc($target_min_size, $target_max_size), fBytes($target_min_size));
  	printf("\tMax Size (High Water):\t\t%d:1\t%s\n",
  		$target_size_ratio, fBytes($target_max_size));
@@ -100,7 +104,7 @@
  	print "\nARC Size Breakdown:\n";
  	if ($arc_size > $target_size) {
  		my $mfu_size = ($arc_size - $mru_size);
-@@ -424,7 +453,7 @@ sub _arc_efficiency {
+@@ -424,7 +455,7 @@ sub _arc_efficiency {
  	printf("\tData Demand Efficiency:\t\t%s\t%s\n",
  		fPerc($demand_data_hits, $demand_data_total), fHits($demand_data_total));
  
@@ -109,7 +113,7 @@
  		printf("\tData Prefetch Efficiency:\t%s\t%s\n",
  			fPerc($prefetch_data_hits, $prefetch_data_total), fHits($prefetch_data_total));
  	}
-@@ -474,6 +503,7 @@ sub _l2arc_summary {
+@@ -474,6 +505,7 @@ sub _l2arc_summary {
  		return;
  	}
  
@@ -117,7 +121,7 @@
  	my $l2_abort_lowmem = $Kstat->{"kstat.zfs.misc.arcstats.l2_abort_lowmem"};
  	my $l2_cksum_bad = $Kstat->{"kstat.zfs.misc.arcstats.l2_cksum_bad"};
  	my $l2_evict_lock_retry = $Kstat->{"kstat.zfs.misc.arcstats.l2_evict_lock_retry"};
-@@ -493,14 +523,13 @@ sub _l2arc_summary {
+@@ -493,14 +525,13 @@ sub _l2arc_summary {
  	my $l2_write_full = $Kstat->{"kstat.zfs.misc.arcstats.l2_write_full"};
  	my $l2_write_in_l2 = $Kstat->{"kstat.zfs.misc.arcstats.l2_write_in_l2"};
  	my $l2_write_io_in_progress = $Kstat->{"kstat.zfs.misc.arcstats.l2_write_io_in_progress"};
@@ -134,7 +138,7 @@
  	my $l2_writes_sent = $Kstat->{"kstat.zfs.misc.arcstats.l2_writes_sent"};
  
  	my $l2_access_total = ($l2_hits + $l2_misses);
-@@ -510,19 +539,28 @@ sub _l2arc_summary {
+@@ -510,19 +541,28 @@ sub _l2arc_summary {
  	if ($l2_health_count > 0) {
  		print "(DEGRADED)\n";
  	} else { print "(HEALTHY)\n"; }
@@ -169,7 +173,7 @@
  	printf("\tHeader Size:\t\t\t%s\t%s\n",
  		fPerc($l2_hdr_size, $l2_size), fBytes($l2_hdr_size));
  	print "\n";
-@@ -541,12 +579,14 @@ sub _l2arc_summary {
+@@ -541,12 +581,14 @@ sub _l2arc_summary {
  	printf("\tFeeds:\t\t\t\t\t%s\n", fHits($l2_feeds));
  	print "\n";
  
@@ -190,7 +194,7 @@
  
  	print "L2 ARC Writes:\n";
  	if ($l2_writes_done != $l2_writes_sent) {
-@@ -582,7 +622,7 @@ sub _vdev_summary {
+@@ -582,7 +624,7 @@ sub _vdev_summary {
  	my $vdev_cache_hits = $Kstat->{"kstat.zfs.misc.vdev_cache_stats.hits"};
  	my $vdev_cache_total = ($vdev_cache_misses + $vdev_cache_hits + $vdev_cache_delegations);
  
@@ -199,7 +203,7 @@
  		printf "VDEV cache is disabled\n";
  	} elsif ($vdev_cache_total > 0) {
  		printf("VDEV Cache Summary:\t\t\t\t%s\n", fHits($vdev_cache_total));
-@@ -595,6 +635,57 @@ sub _vdev_summary {
+@@ -595,6 +637,57 @@ sub _vdev_summary {
  	}
  }
  
@@ -257,7 +261,17 @@
  sub _sysctl_summary {
  	return unless $usetunable;
  	my @Tunable = qw(
-@@ -633,6 +724,7 @@ my @unSub = map { $_, \&div2 }(
+@@ -619,7 +712,8 @@ sub _sysctl_summary {
+ 	foreach my $tunable (@tunable){
+ 		chomp($tunable);
+ 		my ($name, $value) = split(/=/, $tunable, 2);
+-		my $format = $alternate_sysctl_layout ? "\t%s=%d\n" : "\t%-40s%d\n";
++		my $typefmt = looks_like_number($value) ? "%d" : "%s";
++		my $format = $alternate_sysctl_layout ? "\t%s=$typefmt\n" : "\t%-40s$typefmt\n";
+ 		if ($show_sysctl_descriptions != 0){
+ 			printf("\t\# %s\n", $sysctl_descriptions{$name});
+ 		}
+@@ -633,6 +727,7 @@ my @unSub = map { $_, \&div2 }(
  	\&_arc_summary,
  	\&_arc_efficiency,
  	\&_l2arc_summary,
@@ -265,7 +279,7 @@
  	\&_dmu_summary,
  	\&_vdev_summary,
  	\&_sysctl_summary,
-@@ -640,7 +732,7 @@ my @unSub = map { $_, \&div2 }(
+@@ -640,7 +735,7 @@ my @unSub = map { $_, \&div2 }(
  
  my %opt;
  GetOptions( \%opt,
@@ -274,7 +288,7 @@
  	h => \&_usage,   # exits
  	V => \&_version, # exits
  	qw"hostname=s user=s id_file=s port=s",
-@@ -676,6 +768,7 @@ if ($opt{a}) {
+@@ -676,6 +771,7 @@ if ($opt{a}) {
  	if ($opt{A}) { push @out, \&_arc_summary, \&div2 }
  	if ($opt{E}) { push @out, \&_arc_efficiency, \&div2 }
  	if ($opt{L}) { push @out, \&_l2arc_summary, \&div2 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102261430.11QEUj8R013502>