check_dns.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*****************************************************************************
  2. *
  3. * Nagios check_dns plugin
  4. *
  5. * License: GPL
  6. * Copyright (c) 2000-2008 Nagios Plugins Development Team
  7. *
  8. * Description:
  9. *
  10. * This file contains the check_dns plugin
  11. *
  12. * LIMITATION: nslookup on Solaris 7 can return output over 2 lines, which
  13. * will not be picked up by this plugin
  14. *
  15. *
  16. * This program is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation, either version 3 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. *
  29. *
  30. *****************************************************************************/
  31. const char *progname = "check_dns";
  32. const char *copyright = "2000-2008";
  33. const char *email = "devel@nagios-plugins.org";
  34. #include "common.h"
  35. #include "utils.h"
  36. #include "utils_base.h"
  37. #include "netutils.h"
  38. #include "runcmd.h"
  39. int process_arguments (int, char **);
  40. int validate_arguments (void);
  41. int error_scan (char *);
  42. void print_help (void);
  43. void print_usage (void);
  44. #define ADDRESS_LENGTH 384
  45. char query_address[ADDRESS_LENGTH] = "";
  46. char dns_server[ADDRESS_LENGTH] = "";
  47. char ptr_server[ADDRESS_LENGTH] = "";
  48. char query_type[16] = "";
  49. int verbose = FALSE;
  50. char **expected_address = NULL;
  51. int expected_address_cnt = 0;
  52. int expect_authority = FALSE;
  53. int accept_cname = FALSE;
  54. thresholds *time_thresholds = NULL;
  55. static int
  56. qstrcmp(const void *p1, const void *p2)
  57. {
  58. /* The actual arguments to this function are "pointers to
  59. pointers to char", but strcmp() arguments are "pointers
  60. to char", hence the following cast plus dereference */
  61. return strcmp(* (char * const *) p1, * (char * const *) p2);
  62. }
  63. char *
  64. check_new_address(char *temp_buffer)
  65. {
  66. temp_buffer++;
  67. /* Strip leading spaces */
  68. for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
  69. /* NOOP */;
  70. strip(temp_buffer);
  71. if (temp_buffer==NULL || strlen(temp_buffer)==0) {
  72. die (STATE_CRITICAL,
  73. _("DNS CRITICAL - '%s' returned empty host name string\n"),
  74. NSLOOKUP_COMMAND);
  75. }
  76. return temp_buffer;
  77. }
  78. int
  79. main (int argc, char **argv)
  80. {
  81. char *command_line = NULL;
  82. char input_buffer[MAX_INPUT_BUFFER];
  83. char *address = NULL; /* comma seperated str with addrs/ptrs (sorted) */
  84. char **addresses = NULL;
  85. int n_addresses = 0;
  86. char *msg = NULL;
  87. char query_found[16] = "";
  88. char *temp_buffer = NULL;
  89. int non_authoritative = TRUE;
  90. int result = STATE_UNKNOWN;
  91. double elapsed_time;
  92. long microsec;
  93. struct timeval tv;
  94. int multi_address;
  95. int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
  96. output chld_out, chld_err;
  97. size_t i;
  98. setlocale (LC_ALL, "");
  99. bindtextdomain (PACKAGE, LOCALEDIR);
  100. textdomain (PACKAGE);
  101. /* Set signal handling and alarm */
  102. if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) {
  103. usage_va(_("Cannot catch SIGALRM"));
  104. }
  105. /* Parse extra opts if any */
  106. argv=np_extra_opts (&argc, argv, progname);
  107. if (process_arguments (argc, argv) == ERROR) {
  108. usage_va(_("Could not parse arguments"));
  109. }
  110. /* get the command to run */
  111. xasprintf (&command_line, "%s %s %s %s", NSLOOKUP_COMMAND, query_type, query_address, dns_server);
  112. alarm (timeout_interval);
  113. gettimeofday (&tv, NULL);
  114. if (verbose)
  115. printf ("%s\n", command_line);
  116. /* run the command */
  117. if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) {
  118. msg = (char *)_("nslookup returned an error status");
  119. result = STATE_WARNING;
  120. }
  121. /* scan stdout */
  122. for(i = 0; i < chld_out.lines; i++) {
  123. if (addresses == NULL)
  124. addresses = malloc(sizeof(*addresses)*10);
  125. else if (!(n_addresses % 10))
  126. addresses = realloc(addresses,sizeof(*addresses) * (n_addresses + 10));
  127. if (verbose)
  128. puts(chld_out.line[i]);
  129. if (strstr (chld_out.line[i], "Authoritative answers can be found from:")) {
  130. non_authoritative = FALSE;
  131. break;
  132. }
  133. /* the server is responding, we just got the host name... */
  134. if (strstr (chld_out.line[i], "Name:"))
  135. parse_address = TRUE;
  136. /* begin handling types of records */
  137. if (strstr (chld_out.line[i], "AAAA address")) {
  138. if (verbose) printf("Found AAAA record\n");
  139. temp_buffer = rindex (chld_out.line[i], ' ');
  140. addresses[n_addresses++] = check_new_address(temp_buffer);
  141. strncpy(query_found, "-querytype=AAAA", sizeof(query_found));
  142. }
  143. else if (strstr (chld_out.line[i], "exchanger =")) {
  144. if (verbose) printf("Found MX record\n");
  145. temp_buffer = index (chld_out.line[i], '=');
  146. addresses[n_addresses++] = check_new_address(temp_buffer);
  147. strncpy(query_found, "-querytype=MX", sizeof(query_found));
  148. }
  149. else if (strstr (chld_out.line[i], "service =")) {
  150. if (verbose) printf("Found SRV record\n");
  151. temp_buffer = index (chld_out.line[i], '=');
  152. addresses[n_addresses++] = check_new_address(temp_buffer);
  153. strncpy(query_found, "-querytype=SRV", sizeof(query_found));
  154. }
  155. else if (accept_cname && strstr (chld_out.line[i], "canonical name =")) {
  156. if (verbose) printf("Found CNAME record\n");
  157. temp_buffer = index (chld_out.line[i], '=');
  158. addresses[n_addresses++] = check_new_address(temp_buffer);
  159. strncpy(query_found, "-querytype=CNAME", sizeof(query_found));
  160. }
  161. else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") || strstr (chld_out.line[i], "Addresses:"))) {
  162. if (verbose) printf("Found A record\n");
  163. temp_buffer = index (chld_out.line[i], ':');
  164. addresses[n_addresses++] = check_new_address(temp_buffer);
  165. strncpy(query_found, "-querytype=A", sizeof(query_found));
  166. }
  167. else if (strstr (chld_out.line[i], "nameserver =")) {
  168. if (verbose) printf("Found NS record\n");
  169. temp_buffer = index (chld_out.line[i], '=');
  170. addresses[n_addresses++] = check_new_address(temp_buffer);
  171. strncpy(query_found, "-querytype=NS", sizeof(query_found));
  172. }
  173. else if (strstr (chld_out.line[i], "dname =")) {
  174. if (verbose) printf("Found DNAME record\n");
  175. temp_buffer = index (chld_out.line[i], '=');
  176. addresses[n_addresses++] = check_new_address(temp_buffer);
  177. strncpy(query_found, "-querytype=DNAME", sizeof(query_found));
  178. }
  179. /* must be after other records with "name" as an identifier, as ptr does not spefify */
  180. else if (strstr (chld_out.line[i], "name =")) {
  181. if (verbose) printf("Found PTR record\n");
  182. temp_buffer = index (chld_out.line[i], '=');
  183. addresses[n_addresses++] = check_new_address(temp_buffer);
  184. strncpy(query_found, "-querytype=PTR", sizeof(query_found));
  185. }
  186. else if (strstr (chld_out.line[i], "protocol =")) {
  187. if (verbose) printf("Found WKS record\n");
  188. temp_buffer = index (chld_out.line[i], '=');
  189. addresses[n_addresses++] = check_new_address(temp_buffer);
  190. strncpy(query_found, "-querytype=WKS", sizeof(query_found));
  191. }
  192. /* TODO: needs to be changed to handle txt output and max size of txt recrods */
  193. else if (strstr (chld_out.line[i], "text =")) {
  194. if (verbose) printf("Found TXT record\n");
  195. temp_buffer = index (chld_out.line[i], '=');
  196. addresses[n_addresses++] = check_new_address(temp_buffer);
  197. strncpy(query_found, "-querytype=TXT", sizeof(query_found));
  198. }
  199. /* only matching for origin records, if requested other fields could be included at a later date */
  200. else if (strstr (chld_out.line[i], "origin =")) {
  201. if (verbose) printf("Found SOA record\n");
  202. temp_buffer = index(chld_out.line[i], '=');
  203. addresses[n_addresses++] = check_new_address(temp_buffer);
  204. strncpy(query_found, "-querytype=SOA", sizeof(query_found));
  205. }
  206. if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {
  207. non_authoritative = TRUE;
  208. }
  209. result = error_scan (chld_out.line[i]);
  210. if (result != STATE_OK) {
  211. msg = strchr (chld_out.line[i], ':');
  212. if(msg) msg++;
  213. break;
  214. }
  215. }
  216. /* scan stderr */
  217. for(i = 0; i < chld_err.lines; i++) {
  218. if (verbose)
  219. puts(chld_err.line[i]);
  220. if (error_scan (chld_err.line[i]) != STATE_OK) {
  221. result = max_state (result, error_scan (chld_err.line[i]));
  222. msg = strchr(input_buffer, ':');
  223. if(msg) msg++;
  224. }
  225. }
  226. if (addresses) {
  227. int i,slen;
  228. char *adrp;
  229. qsort(addresses, n_addresses, sizeof(*addresses), qstrcmp);
  230. for(i=0, slen=1; i < n_addresses; i++) {
  231. slen += strlen(addresses[i])+1;
  232. }
  233. adrp = address = malloc(slen);
  234. for(i=0; i < n_addresses; i++) {
  235. if (i) *adrp++ = ',';
  236. strcpy(adrp, addresses[i]);
  237. adrp += strlen(addresses[i]);
  238. }
  239. *adrp = 0;
  240. } else
  241. die (STATE_CRITICAL,
  242. _("DNS CRITICAL - '%s' msg parsing exited with no address\n"),
  243. NSLOOKUP_COMMAND);
  244. /* compare to expected address */
  245. if (result == STATE_OK && expected_address_cnt > 0) {
  246. result = STATE_CRITICAL;
  247. temp_buffer = "";
  248. for (i=0; i<expected_address_cnt; i++) {
  249. /* check if we get a match and prepare an error string */
  250. if (strcmp(address, expected_address[i]) == 0) result = STATE_OK;
  251. xasprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]);
  252. }
  253. if (result == STATE_CRITICAL) {
  254. /* Strip off last semicolon... */
  255. temp_buffer[strlen(temp_buffer)-2] = '\0';
  256. xasprintf(&msg, _("expected '%s' but got '%s'"), temp_buffer, address);
  257. }
  258. }
  259. /* check if authoritative */
  260. if (result == STATE_OK && expect_authority && !non_authoritative) {
  261. result = STATE_CRITICAL;
  262. if (strncmp(dns_server, "", 1))
  263. xasprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address);
  264. else
  265. xasprintf(&msg, _("there is no authoritative server for %s"), query_address);
  266. }
  267. /* compare query type to query found, if query type is ANY we can skip as any record is accepted*/
  268. if (result == STATE_OK && strncmp(query_type, "", 1) && (strncmp(query_type, "-querytype=ANY", 15) != 0)) {
  269. if (strncmp(query_type, query_found, 16) != 0) {
  270. if (verbose)
  271. printf( "Failed query for %s only found %s, or nothing\n", query_type, query_found);
  272. result = STATE_CRITICAL;
  273. xasprintf(&msg, _("query type of %s was not found for %s"), query_type, query_address);
  274. }
  275. }
  276. microsec = deltime (tv);
  277. elapsed_time = (double)microsec / 1.0e6;
  278. if (result == STATE_OK) {
  279. if (strchr (address, ',') == NULL)
  280. multi_address = FALSE;
  281. else
  282. multi_address = TRUE;
  283. result = get_status(elapsed_time, time_thresholds);
  284. if (result == STATE_OK) {
  285. printf ("DNS %s: ", _("OK"));
  286. } else if (result == STATE_WARNING) {
  287. printf ("DNS %s: ", _("WARNING"));
  288. } else if (result == STATE_CRITICAL) {
  289. printf ("DNS %s: ", _("CRITICAL"));
  290. }
  291. printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
  292. printf (_(". %s returns %s"), query_address, address);
  293. if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) {
  294. printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
  295. TRUE, time_thresholds->warning->end,
  296. TRUE, time_thresholds->critical->end,
  297. TRUE, 0, FALSE, 0));
  298. } else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) {
  299. printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
  300. FALSE, 0,
  301. TRUE, time_thresholds->critical->end,
  302. TRUE, 0, FALSE, 0));
  303. } else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) {
  304. printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
  305. TRUE, time_thresholds->warning->end,
  306. FALSE, 0,
  307. TRUE, 0, FALSE, 0));
  308. } else
  309. printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
  310. }
  311. else if (result == STATE_WARNING)
  312. printf (_("DNS WARNING - %s\n"),
  313. !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
  314. else if (result == STATE_CRITICAL)
  315. printf (_("DNS CRITICAL - %s\n"),
  316. !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
  317. else
  318. printf (_("DNS UNKNOWN - %s\n"),
  319. !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
  320. return result;
  321. }
  322. int
  323. error_scan (char *input_buffer)
  324. {
  325. /* the DNS lookup timed out */
  326. if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) ||
  327. strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) ||
  328. strstr (input_buffer, _("the `-sil[ent]' option to prevent this message from appearing.")))
  329. return STATE_OK;
  330. /* DNS server is not running... */
  331. else if (strstr (input_buffer, "No response from server"))
  332. die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
  333. /* Host name is valid, but server doesn't have records... */
  334. else if (strstr (input_buffer, "No records") || strstr (input_buffer, "No answer"))
  335. die (STATE_CRITICAL, _("DNS %s has no records\n"), dns_server);
  336. /* Connection was refused */
  337. else if (strstr (input_buffer, "Connection refused") ||
  338. strstr (input_buffer, "Couldn't find server") ||
  339. strstr (input_buffer, "Refused") ||
  340. (strstr (input_buffer, "** server can't find") &&
  341. strstr (input_buffer, ": REFUSED")))
  342. die (STATE_CRITICAL, _("Connection to DNS %s was refused\n"), dns_server);
  343. /* Query refused (usually by an ACL in the namserver) */
  344. else if (strstr (input_buffer, "Query refused"))
  345. die (STATE_CRITICAL, _("Query was refused by DNS server at %s\n"), dns_server);
  346. /* No information (e.g. nameserver IP has two PTR records) */
  347. else if (strstr (input_buffer, "No information"))
  348. die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server);
  349. /* Host or domain name does not exist */
  350. else if (strstr (input_buffer, "Non-existent") ||
  351. strstr (input_buffer, "** server can't find") ||
  352. strstr (input_buffer,"NXDOMAIN"))
  353. die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address);
  354. /* Network is unreachable */
  355. else if (strstr (input_buffer, "Network is unreachable"))
  356. die (STATE_CRITICAL, _("Network is unreachable\n"));
  357. /* Internal server failure */
  358. else if (strstr (input_buffer, "Server failure"))
  359. die (STATE_CRITICAL, _("DNS failure for %s\n"), dns_server);
  360. /* Request error or the DNS lookup timed out */
  361. else if (strstr (input_buffer, "Format error") ||
  362. strstr (input_buffer, "Timed out"))
  363. return STATE_WARNING;
  364. return STATE_OK;
  365. }
  366. /* process command-line arguments */
  367. int
  368. process_arguments (int argc, char **argv)
  369. {
  370. int c;
  371. char *warning = NULL;
  372. char *critical = NULL;
  373. int opt_index = 0;
  374. static struct option long_opts[] = {
  375. {"help", no_argument, 0, 'h'},
  376. {"version", no_argument, 0, 'V'},
  377. {"verbose", no_argument, 0, 'v'},
  378. {"timeout", required_argument, 0, 't'},
  379. {"hostname", required_argument, 0, 'H'},
  380. {"server", required_argument, 0, 's'},
  381. {"reverse-server", required_argument, 0, 'r'},
  382. {"querytype", required_argument, 0, 'q'},
  383. {"expected-address", required_argument, 0, 'a'},
  384. {"expect-authority", no_argument, 0, 'A'},
  385. {"accept-cname", no_argument, 0, 'n'},
  386. {"warning", required_argument, 0, 'w'},
  387. {"critical", required_argument, 0, 'c'},
  388. {0, 0, 0, 0}
  389. };
  390. if (argc < 2)
  391. return ERROR;
  392. for (c = 1; c < argc; c++)
  393. if (strcmp ("-to", argv[c]) == 0)
  394. strcpy (argv[c], "-t");
  395. while (1) {
  396. c = getopt_long (argc, argv, "hVvAnt:H:s:r:a:q:w:c:", long_opts, &opt_index);
  397. if (c == -1 || c == EOF)
  398. break;
  399. switch (c) {
  400. case 'h': /* help */
  401. print_help ();
  402. exit (STATE_OK);
  403. case 'V': /* version */
  404. print_revision (progname, NP_VERSION);
  405. exit (STATE_OK);
  406. case 'v': /* version */
  407. verbose = TRUE;
  408. break;
  409. case 't': /* timeout period */
  410. timeout_interval = atoi (optarg);
  411. break;
  412. case 'H': /* hostname */
  413. if (strlen (optarg) >= ADDRESS_LENGTH)
  414. die (STATE_UNKNOWN, _("Input buffer overflow\n"));
  415. strcpy (query_address, optarg);
  416. break;
  417. case 's': /* server name */
  418. /* TODO: this host_or_die check is probably unnecessary.
  419. * Better to confirm nslookup response matches */
  420. host_or_die(optarg);
  421. if (strlen (optarg) >= ADDRESS_LENGTH)
  422. die (STATE_UNKNOWN, _("Input buffer overflow\n"));
  423. strcpy (dns_server, optarg);
  424. break;
  425. case 'r': /* reverse server name */
  426. /* TODO: Is this host_or_die necessary? */
  427. host_or_die(optarg);
  428. if (strlen (optarg) >= ADDRESS_LENGTH)
  429. die (STATE_UNKNOWN, _("Input buffer overflow\n"));
  430. strcpy (ptr_server, optarg);
  431. break;
  432. case 'a': /* expected address */
  433. if (strlen (optarg) >= ADDRESS_LENGTH)
  434. die (STATE_UNKNOWN, _("Input buffer overflow\n"));
  435. expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
  436. expected_address[expected_address_cnt] = strdup(optarg);
  437. expected_address_cnt++;
  438. break;
  439. case 'q': /* querytype -- A or AAAA or ANY or SRV or TXT, etc. */
  440. if (strlen (optarg) < 1 || strlen (optarg) > 5)
  441. die (STATE_UNKNOWN, _("Missing valid querytype parameter. Try using 'A' or 'AAAA' or 'SRV'\n"));
  442. strntoupper(optarg, sizeof(optarg));
  443. strcpy(query_type, "-querytype=");
  444. strcat(query_type, optarg);
  445. break;
  446. case 'A': /* expect authority */
  447. expect_authority = TRUE;
  448. break;
  449. case 'n': /* accept cname responses as a result */
  450. accept_cname = TRUE;
  451. break;
  452. case 'w':
  453. warning = optarg;
  454. break;
  455. case 'c':
  456. critical = optarg;
  457. break;
  458. default: /* args not parsable */
  459. usage5();
  460. }
  461. }
  462. c = optind;
  463. if (strlen(query_address)==0 && c<argc) {
  464. if (strlen(argv[c])>=ADDRESS_LENGTH)
  465. die (STATE_UNKNOWN, _("Input buffer overflow\n"));
  466. strcpy (query_address, argv[c++]);
  467. }
  468. if (strlen(dns_server)==0 && c<argc) {
  469. /* TODO: See -s option */
  470. host_or_die(argv[c]);
  471. if (strlen(argv[c]) >= ADDRESS_LENGTH)
  472. die (STATE_UNKNOWN, _("Input buffer overflow\n"));
  473. strcpy (dns_server, argv[c++]);
  474. }
  475. set_thresholds(&time_thresholds, warning, critical);
  476. return validate_arguments ();
  477. }
  478. int
  479. validate_arguments ()
  480. {
  481. if (query_address[0] == 0)
  482. return ERROR;
  483. return OK;
  484. }
  485. void
  486. print_help (void)
  487. {
  488. print_revision (progname, NP_VERSION);
  489. printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
  490. printf (COPYRIGHT, copyright, email);
  491. printf ("%s\n", _("This plugin uses the nslookup program to obtain the IP address for the given host/domain query."));
  492. printf ("%s\n", _("An optional DNS server to use may be specified."));
  493. printf ("%s\n", _("If no DNS server is specified, the default server(s) specified in /etc/resolv.conf will be used."));
  494. printf ("\n\n");
  495. print_usage ();
  496. printf (UT_HELP_VRSN);
  497. printf (UT_EXTRA_OPTS);
  498. printf (" -H, --hostname=HOST\n");
  499. printf (" %s\n", _("The name or address you want to query"));
  500. printf (" -s, --server=HOST\n");
  501. printf (" %s\n", _("Optional DNS server you want to use for the lookup"));
  502. printf (" -q, --querytype=TYPE\n");
  503. printf (" %s\n", _("Optional DNS record query type where TYPE =(A, AAAA, SRV, TXT, MX, ANY)"));
  504. printf (" %s\n", _("The default query type is 'A' (IPv4 host entry)"));
  505. printf (" -a, --expected-address=IP-ADDRESS|HOST\n");
  506. printf (" %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with"));
  507. printf (" %s\n", _("a dot (.). This option can be repeated multiple times (Returns OK if any"));
  508. printf (" %s\n", _("value match). If multiple addresses are returned at once, you have to match"));
  509. printf (" %s\n", _("the whole string of addresses separated with commas (sorted alphabetically)."));
  510. printf (" %s\n", _("If you would like to test for the presence of a cname, combine with -n param."));
  511. printf (" -A, --expect-authority\n");
  512. printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
  513. printf (" -n, --accept-cname\n");
  514. printf (" %s\n", _("Optionally accept cname responses as a valid result to a query"));
  515. printf (" %s\n", _("The default is to ignore cname responses as part of the result"));
  516. printf (" -w, --warning=seconds\n");
  517. printf (" %s\n", _("Return warning if elapsed time exceeds value. Default off"));
  518. printf (" -c, --critical=seconds\n");
  519. printf (" %s\n", _("Return critical if elapsed time exceeds value. Default off"));
  520. printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
  521. printf (UT_SUPPORT);
  522. }
  523. void
  524. print_usage (void)
  525. {
  526. printf ("%s\n", _("Usage:"));
  527. printf ("%s -H host [-s server] [-q type ] [-a expected-address] [-A] [-n] [-t timeout] [-w warn] [-c crit]\n", progname);
  528. }