# HG changeset patch # User Fabian Keil # Date 1309707359 -7200 # Node ID 7acc1670efd9a025fbbecad418feabf2b9636044 # Parent c9147a046a58d4534d9a1c51727f95de4630d5a6 Add a -d flag to let _sysctl_summary() additionally show the the sysctl descriptions diff -r c9147a046a58 -r 7acc1670efd9 base/head/scripts/zfs/arc_summary/arc_summary.pl --- a/base/head/scripts/zfs/arc_summary/arc_summary.pl Fri Jul 01 21:48:55 2011 +0200 +++ b/base/head/scripts/zfs/arc_summary/arc_summary.pl Sun Jul 03 17:35:59 2011 +0200 @@ -46,7 +46,9 @@ use Getopt::Std; use Switch 'Perl5', 'Perl6'; -my $usetunable = 1; # Change to 0 to disable sysctl MIB spill. +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. +my $description_behind_sysctl = 1; # Change to 0 to print the sysctl description on its own line. sub hline { print "\n------------------------------------------------------------------------\n\n"; @@ -571,19 +573,36 @@ } sub _sysctl_summary { - if ($usetunable != 0) { - my @Tunable = qw( - kern.maxusers - vfs.zfs - vm.kmem_size - vm.kmem_size_scale - vm.kmem_size_min - vm.kmem_size_max - ); - my @tunable = `/sbin/sysctl -qe @Tunable`; - print "ZFS Tunable (sysctl):\n"; - foreach my $tunable (@tunable){ - chomp($tunable); + return unless $usetunable; + my @Tunable = qw( + kern.maxusers + vfs.zfs + vm.kmem_size + vm.kmem_size_scale + vm.kmem_size_min + vm.kmem_size_max + ); + my %sysctl_descriptions; + if ($show_sysctl_descriptions) { + foreach my $tunable (`/sbin/sysctl -de @Tunable`){ + chomp $tunable; + my ($name, $description) = split(/=/, $tunable, 2); + $description = "Description unavailable" unless $description; + $sysctl_descriptions{$name}=$description; + } + } + my @tunable = `/sbin/sysctl -qe @Tunable`; + print "ZFS Tunable (sysctl):\n"; + foreach my $tunable (@tunable){ + chomp($tunable); + my ($name, $value) = split(/=/, $tunable, 2); + if ($show_sysctl_descriptions) { + if ($description_behind_sysctl) { + printf("\t%-32s = %15d %s\n", $name, $value, $sysctl_descriptions{$name}); + } else { + printf("\n\t%s:\n\t%-32s = %15d\n", $sysctl_descriptions{$name}, $name, $value); + } + } else { print "\t$tunable\n"; } } @@ -611,8 +630,9 @@ } my %opt; -getopt("p:", \%opt); +getopts("dp:", \%opt); if (%opt) { + $show_sysctl_descriptions = 1 if $opt{d}; switch($opt{p}) { case 1 { eval $unSub[0]; hline; } case 2 { eval $unSub[1]; hline; }