diff options
Diffstat (limited to 'web/attachments/154471-nagios_plugins-check_dns.c.patch')
| -rw-r--r-- | web/attachments/154471-nagios_plugins-check_dns.c.patch | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/web/attachments/154471-nagios_plugins-check_dns.c.patch b/web/attachments/154471-nagios_plugins-check_dns.c.patch new file mode 100644 index 0000000..f024078 --- /dev/null +++ b/web/attachments/154471-nagios_plugins-check_dns.c.patch | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | --- ../../original_sources/nagios-plugins-1.4.2/plugins/check_dns.c 2004-12-29 19:41:39.000000000 -0500 | ||
| 2 | +++ nagios-plugins-1.4.2/plugins/check_dns.c 2005-10-19 22:54:35.000000000 -0400 | ||
| 3 | @@ -45,6 +45,8 @@ | ||
| 4 | char expected_address[ADDRESS_LENGTH] = ""; | ||
| 5 | int match_expected_address = FALSE; | ||
| 6 | int expect_authority = FALSE; | ||
| 7 | +double elapsed_warn_time = 0.0; | ||
| 8 | +double elapsed_crit_time = 0.0; | ||
| 9 | |||
| 10 | int | ||
| 11 | main (int argc, char **argv) | ||
| 12 | @@ -193,6 +195,21 @@ | ||
| 13 | microsec = deltime (tv); | ||
| 14 | elapsed_time = (double)microsec / 1.0e6; | ||
| 15 | |||
| 16 | + | ||
| 17 | + /* check elapsed time */ | ||
| 18 | + if ((result == STATE_OK) && | ||
| 19 | + ((elapsed_warn_time != 0.0) && (elapsed_warn_time <= elapsed_time)) && | ||
| 20 | + ((elapsed_crit_time == 0.0) || elapsed_crit_time > elapsed_time) ) { | ||
| 21 | + result = STATE_WARNING; | ||
| 22 | + asprintf(&output, _("server %s responded too slowly. %.5f seconds response time."), dns_server, elapsed_time); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + if ((result == STATE_OK) && (elapsed_crit_time != 0) && | ||
| 26 | + (elapsed_crit_time <= elapsed_time) ) { | ||
| 27 | + result = STATE_CRITICAL; | ||
| 28 | + asprintf(&output, _("server %s responded too slowly. %.5f seconds response time."), dns_server, elapsed_time); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | if (result == STATE_OK) { | ||
| 32 | if (strchr (address, ',') == NULL) | ||
| 33 | multi_address = FALSE; | ||
| 34 | @@ -200,7 +217,7 @@ | ||
| 35 | multi_address = TRUE; | ||
| 36 | |||
| 37 | printf ("DNS %s: ", _("OK")); | ||
| 38 | - printf (ngettext("%.3f second response time ", "%.3f seconds response time ", elapsed_time), elapsed_time); | ||
| 39 | + printf (ngettext("%.5f second response time ", "%.5f seconds response time ", elapsed_time), elapsed_time); | ||
| 40 | printf (_("%s returns %s"), query_address, address); | ||
| 41 | printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); | ||
| 42 | } | ||
| 43 | @@ -294,6 +311,8 @@ | ||
| 44 | {"reverse-server", required_argument, 0, 'r'}, | ||
| 45 | {"expected-address", required_argument, 0, 'a'}, | ||
| 46 | {"expect-authority", no_argument, 0, 'A'}, | ||
| 47 | + {"warning", required_argument, 0, 'w'}, | ||
| 48 | + {"critical", required_argument, 0, 'c'}, | ||
| 49 | {0, 0, 0, 0} | ||
| 50 | }; | ||
| 51 | |||
| 52 | @@ -305,7 +324,7 @@ | ||
| 53 | strcpy (argv[c], "-t"); | ||
| 54 | |||
| 55 | while (1) { | ||
| 56 | - c = getopt_long (argc, argv, "hVvAt:H:s:r:a:", long_opts, &opt_index); | ||
| 57 | + c = getopt_long (argc, argv, "hVvAt:H:s:r:a:w:c:", long_opts, &opt_index); | ||
| 58 | |||
| 59 | if (c == -1 || c == EOF) | ||
| 60 | break; | ||
| 61 | @@ -358,6 +377,12 @@ | ||
| 62 | case 'A': /* expect authority */ | ||
| 63 | expect_authority = TRUE; | ||
| 64 | break; | ||
| 65 | + case 'w': /* elapsed time > warning */ | ||
| 66 | + elapsed_warn_time = atof (optarg); | ||
| 67 | + break; | ||
| 68 | + case 'c': /* elapsed time > critical */ | ||
| 69 | + elapsed_crit_time = atof (optarg); | ||
| 70 | + break; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | @@ -387,11 +412,13 @@ | ||
| 75 | validate_arguments () | ||
| 76 | { | ||
| 77 | if (query_address[0] == 0) | ||
| 78 | - return ERROR; | ||
| 79 | - else | ||
| 80 | - return OK; | ||
| 81 | -} | ||
| 82 | + usage4 (_("Can't determine/parse address to query.")); | ||
| 83 | + | ||
| 84 | + if ( elapsed_crit_time != 0.0 && elapsed_warn_time > elapsed_crit_time ) | ||
| 85 | + usage4 (_("Warning time must be less than critical time.")); | ||
| 86 | |||
| 87 | + return OK; | ||
| 88 | +} | ||
| 89 | |||
| 90 | void | ||
| 91 | print_help (void) | ||
| 92 | @@ -419,7 +446,13 @@ | ||
| 93 | -a, --expected-address=IP-ADDRESS\n\ | ||
| 94 | Optional IP address you expect the DNS server to return\n\ | ||
| 95 | -A, --expect-authority\n\ | ||
| 96 | - Optionally expect the DNS server to be authoritative for the lookup\n")); | ||
| 97 | + Optionally expect the DNS server to be authoritative for the lookup\n\ | ||
| 98 | +-w, --warning=seconds\n\ | ||
| 99 | + Return warning if elapsed time exceeds value. Default is 0.0 seconds (off).\n\ | ||
| 100 | +-c, --critical=seconds\n\ | ||
| 101 | + Return critical if elapsed time exceeds value. Default is 0.0 seconds (off).\n\ | ||
| 102 | +\n\ | ||
| 103 | +seconds are floating point values. Set to 0 turn off check.\n")); | ||
| 104 | |||
| 105 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
| 106 | |||
| 107 | @@ -431,5 +464,5 @@ | ||
| 108 | print_usage (void) | ||
| 109 | { | ||
| 110 | printf ("\ | ||
| 111 | -Usage: %s -H host [-s server] [-a expected-address] [-A] [-t timeout]\n", progname); | ||
| 112 | +Usage: %s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit]\n", progname); | ||
| 113 | } | ||
