local: read from nzf
authorheiko
Mon, 19 Jan 2015 12:01:39 +0100
changeset 25 88749a69668e
parent 24 d20452378ead
child 26 d465c78373ca
local: read from nzf
lib/Nagios/Check/DNS/delegation.pm
--- a/lib/Nagios/Check/DNS/delegation.pm	Mon Jan 19 11:34:00 2015 +0100
+++ b/lib/Nagios/Check/DNS/delegation.pm	Mon Jan 19 12:01:39 2015 +0100
@@ -28,7 +28,19 @@
 # bind
 sub get_local_zones {
     my @conf;
-    open(my $z, '-|', 'named-checkconf -p');
+    open(my $z, '-|') or do {
+        my $bind_directory;
+        open(my $x, '-|', 'named-checkconf -p');
+        while (<$x>) {
+            /^\s*directory\s+"(.*)";/ and $bind_directory = $1;
+            print;
+        }
+        if (defined $bind_directory) {
+            local @ARGV = grep { -f } glob "$bind_directory/*nzf";
+            print <> if @ARGV;
+        }
+        exit 0;
+    };
     while (<$z>) {
         state $line;
         s/^\s*(.*?)\s*$/$1 /;