Fix nzf parser for comment lines
authorHeiko Schlittermann <hs@schlittermann.de>
Tue, 12 Jul 2016 16:09:05 +0200
changeset 46 1e2d9d329192
parent 45 488c55f6e894
child 47 04515ae2bdca
Fix nzf parser for comment lines
lib/Nagios/Check/DNS/delegation.pm
--- a/lib/Nagios/Check/DNS/delegation.pm	Thu Oct 15 15:09:08 2015 +0200
+++ b/lib/Nagios/Check/DNS/delegation.pm	Tue Jul 12 16:09:05 2016 +0200
@@ -42,6 +42,7 @@
         exit 0;
     };
     while (<$z>) {
+        /^#/ and next;         # comment
         state $line;
         s/^\s*(.*?)\s*$/$1 /;
         chomp($line .= $_);    # continuation line
@@ -51,7 +52,7 @@
             $line = '';
         }
     }
-    return grep { 
+    return grep {
 	# FIXME: 172.0 .. 172.31 is missing
 	not /\b(?:0|127|10|168\.192|255)\.in-addr\.arpa$/ and
 	not /^localhost$/;
@@ -155,7 +156,7 @@
         local $" = ', ';
         die sprintf "NS differ (%s: @our) vs (public: @public)\n",
             $is_override ? 'override' : 'our';
-    
+
     }
 
     @ns = uniq sort @our, @public;
@@ -171,7 +172,7 @@
     if (uniq(map { /(\d+)/ } @serials) != 1) {
         die "serials do not match: @serials\n";
     }
-    
+
     $serials[0] =~ /(\d+)/;
     return $1;
 }
@@ -181,7 +182,7 @@
     my $opt_reference = '127.0.0.1';
     my $opt_progress  = -t;
     my ($opt_override)= grep { -f } '/etc/check_dns-delegation/override';
-                        
+
 
     GetOptionsFromArray(
         \@argv,
@@ -208,9 +209,9 @@
         state $i++;
         print STDERR "$domain ($i/$all) " if $opt_progress;
 
-        my @ns = eval { ns_ok($domain, $override{$domain} ? $override{$domain} : [$opt_reference], 
+        my @ns = eval { ns_ok($domain, $override{$domain} ? $override{$domain} : [$opt_reference],
                               $override{$domain}) };
-	if ($@) { 
+	if ($@) {
             $CRITICAL{$domain} = $@;
             say STDERR 'fail(ns)' if $opt_progress;
             next;