Date: 07 Feburary 2008 Author: Jethro Carr working for Prophecy Networks NZ. Details: Fixed check_dig plugin to make the dig command in the backend run for the specified time period. --- nagios-plugins-1.4.1/plugins/check_dig.c 2005-01-27 10:21:01.000000000 +1300 --- nagios-plugins-1.4.11.orig/plugins/check_dig.c 2007-01-29 10:46:41.000000000 +1300 +++ nagios-plugins-1.4.11/plugins/check_dig.c 2008-02-07 10:59:46.000000000 +1300 @@ -54,6 +54,8 @@ #define UNDEFINED 0 #define DEFAULT_PORT 53 +#define DEFAULT_TRIES 3 +#define DEFAULT_TIMEOUT 10 char *query_address = NULL; char *record_type = "A"; @@ -61,6 +63,7 @@ char *dns_server = NULL; int verbose = FALSE; int server_port = DEFAULT_PORT; +int number_tries = DEFAULT_TRIES; double warning_interval = UNDEFINED; double critical_interval = UNDEFINED; struct timeval tv; @@ -76,6 +79,7 @@ long microsec; double elapsed_time; int result = STATE_UNKNOWN; + timeout_interval = DEFAULT_TIMEOUT; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -88,9 +92,13 @@ if (process_arguments (argc, argv) == ERROR) usage_va(_("Could not parse arguments")); + /* dig applies the timeout to each try, so we need to work around this */ + int timeout_interval_dig = ceil((double) timeout_interval / (double) number_tries); + /* get the command to run */ - asprintf (&command_line, "%s @%s -p %d %s -t %s", - PATH_TO_DIG, dns_server, server_port, query_address, record_type); + asprintf (&command_line, "%s @%s -p %d %s -t %s +tries=%d +time=%d", + PATH_TO_DIG, dns_server, server_port, query_address, record_type, number_tries, timeout_interval_dig); + alarm (timeout_interval); gettimeofday (&tv, NULL);