-my $USAGE = "Usage: $PROGRAM_NAME [--help] | [--warn=<nn>] [--critical=<nn>] <indir>\n";
-my $params = { 'warn' => '14d', 'critical' => '7d' };
+sub check_one {
+ $SIG{'KILL'} = sub { threads->exit(); };
+
+ my $zone = shift;
+ my $check = shift;
+ my $extra = shift;
+ my $params = shift;
+
+ my @cmd = ($check, '-w', $params->{'warn'}, '-c', $params->{'critical'});
+ push(@cmd, '-r', $extra->{'initial_refs'}) if exists $extra->{'initial_refs'};
+ push(@cmd, '-d') if $params->{'debug'};
+ push(@cmd, $zone);
+ open(P, '-|', @cmd) or die ("Cannot run $CHECK for $zone\n");
+ my @p = <P>;
+ close P;
+ $p[0] = $zone.': '. $p[0] if (scalar @p > 0);
+
+ my $res = $CHILD_ERROR >> 8;
+
+ return ($res, \@p);
+}
+
+my $USAGE = "Usage: $PROGRAM_NAME [--help] | [--debug] [--timeout=<nn>] [--warn=<nn>] [--critical=<nn>] [--geozonedir=<geodir>] <indir>\n";
+my $params = { 'timeout' => 45, 'warn' => '14d', 'critical' => '7d' };