my $cmd;

unless( $cmd = $memory{"cmd_$args{frequency}"} ) {
    &uxmon::load_module( "cmd" );
    &uxmon::checker(
	$memory{"cmd_$args{frequency}"} = $cmd = Monitor::cmd->new()
    );
    $cmd->sched_frequency( $args{"frequency"} );
}

# Detect Bind 9, Bind <9, fallback to nslookup
# Check modified from diskfree's algorithm

my ($dnscomm, $maybecomm);
foreach my $dns ( "host -W 4 -R 2 ", "host -s 4 ", "nslookup -retry=2 -timeout=4 " ) {
    my $tst = `sh -c '$dns localhost.' 2>/dev/null`;
    next if ( $? || ! $tst);
    if( $tst =~ /127\.0\.0\.1/ ) {
	$dnscomm = $dns;
	last;
    }
    $maybecomm = $dns;
}
if( $maybecomm && ! $dnscomm ) {
    $dnscomm = $maybecomm;
}
unless( $dnscomm ) {
    BigSister::common::log( "warn", "no compliant host/nslookup command/options found" );
    die();
}

$cmd->add_check( $args{"alias"}.".dns", "$dnscomm $args{host} $args{host}", 
		 [ 0, "green", "dns OK" ], [ "timeout", "red", "dns TIMEOUT" ], [ "*", "red", "dns FAILURE" ] );

1;
