diff options
Diffstat (limited to 'plugins/check_dig.c')
-rw-r--r-- | plugins/check_dig.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index 445b04f..d9481f2 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /***************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | * |
3 | * Nagios check_dig plugin | 3 | * Monitoring check_dig plugin |
4 | * | 4 | * |
5 | * License: GPL | 5 | * License: GPL |
6 | * Copyright (c) 2002-2008 Nagios Plugins Development Team | 6 | * Copyright (c) 2002-2008 Monitoring Plugins Development Team |
7 | * | 7 | * |
8 | * Description: | 8 | * Description: |
9 | * | 9 | * |
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | const char *progname = "check_dig"; | 35 | const char *progname = "check_dig"; |
36 | const char *copyright = "2002-2008"; | 36 | const char *copyright = "2002-2008"; |
37 | const char *email = "devel@nagios-plugins.org"; | 37 | const char *email = "devel@monitoring-plugins.org"; |
38 | 38 | ||
39 | #include "common.h" | 39 | #include "common.h" |
40 | #include "netutils.h" | 40 | #include "netutils.h" |
@@ -48,6 +48,7 @@ void print_usage (void); | |||
48 | 48 | ||
49 | #define UNDEFINED 0 | 49 | #define UNDEFINED 0 |
50 | #define DEFAULT_PORT 53 | 50 | #define DEFAULT_PORT 53 |
51 | #define DEFAULT_TRIES 3 | ||
51 | 52 | ||
52 | char *query_address = NULL; | 53 | char *query_address = NULL; |
53 | char *record_type = "A"; | 54 | char *record_type = "A"; |
@@ -57,6 +58,7 @@ char *dig_args = ""; | |||
57 | char *query_transport = ""; | 58 | char *query_transport = ""; |
58 | int verbose = FALSE; | 59 | int verbose = FALSE; |
59 | int server_port = DEFAULT_PORT; | 60 | int server_port = DEFAULT_PORT; |
61 | int number_tries = DEFAULT_TRIES; | ||
60 | double warning_interval = UNDEFINED; | 62 | double warning_interval = UNDEFINED; |
61 | double critical_interval = UNDEFINED; | 63 | double critical_interval = UNDEFINED; |
62 | struct timeval tv; | 64 | struct timeval tv; |
@@ -72,6 +74,7 @@ main (int argc, char **argv) | |||
72 | long microsec; | 74 | long microsec; |
73 | double elapsed_time; | 75 | double elapsed_time; |
74 | int result = STATE_UNKNOWN; | 76 | int result = STATE_UNKNOWN; |
77 | int timeout_interval_dig; | ||
75 | 78 | ||
76 | setlocale (LC_ALL, ""); | 79 | setlocale (LC_ALL, ""); |
77 | bindtextdomain (PACKAGE, LOCALEDIR); | 80 | bindtextdomain (PACKAGE, LOCALEDIR); |
@@ -87,9 +90,12 @@ main (int argc, char **argv) | |||
87 | if (process_arguments (argc, argv) == ERROR) | 90 | if (process_arguments (argc, argv) == ERROR) |
88 | usage_va(_("Could not parse arguments")); | 91 | usage_va(_("Could not parse arguments")); |
89 | 92 | ||
93 | /* dig applies the timeout to each try, so we need to work around this */ | ||
94 | timeout_interval_dig = timeout_interval / number_tries + number_tries; | ||
95 | |||
90 | /* get the command to run */ | 96 | /* get the command to run */ |
91 | xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s", | 97 | xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s +tries=%d +time=%d", |
92 | PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport); | 98 | PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport, number_tries, timeout_interval_dig); |
93 | 99 | ||
94 | alarm (timeout_interval); | 100 | alarm (timeout_interval); |
95 | gettimeofday (&tv, NULL); | 101 | gettimeofday (&tv, NULL); |
@@ -348,7 +354,7 @@ print_help (void) | |||
348 | printf (" %s\n","-A, --dig-arguments=STRING"); | 354 | printf (" %s\n","-A, --dig-arguments=STRING"); |
349 | printf (" %s\n",_("Pass STRING as argument(s) to dig")); | 355 | printf (" %s\n",_("Pass STRING as argument(s) to dig")); |
350 | printf (UT_WARN_CRIT); | 356 | printf (UT_WARN_CRIT); |
351 | printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 357 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
352 | printf (UT_VERBOSE); | 358 | printf (UT_VERBOSE); |
353 | 359 | ||
354 | printf ("\n"); | 360 | printf ("\n"); |