From ef381d780d04597a53dc787fea447ca4baabb156 Mon Sep 17 00:00:00 2001 From: Tim Pozar Date: Thu, 27 May 2021 12:36:59 -0700 Subject: [PATCH] Error checking with two line stats (#365) * Error checking with two line stats * Fixed some spacing problems --- snmp/zfs-freebsd | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/snmp/zfs-freebsd b/snmp/zfs-freebsd index e4d27cf..c1654f4 100644 --- a/snmp/zfs-freebsd +++ b/snmp/zfs-freebsd @@ -74,9 +74,12 @@ my @sysctls_pull = `/sbin/sysctl -q @to_pull`; foreach my $stat (@sysctls_pull) { chomp( $stat ); my ( $var, $val ) = split(/:/, $stat, 2); - - $val =~ s/^ //; - $sysctls->{$var}=$val; + # If $val is empty, skip it. Likely a var with a newline before + # the data so it is trying to "split" the data. + if( length $val ) { + $val =~ s/^ //; + $sysctls->{$var}=$val; + } } # does not seem to exist for me, but some of these don't seem to be created till needed