check_tcp.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*****************************************************************************
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  13. $Id$
  14. *****************************************************************************/
  15. /* progname "check_tcp" changes depending on symlink called */
  16. char *progname;
  17. const char *revision = "$Revision$";
  18. const char *copyright = "1999-2004";
  19. const char *email = "nagiosplug-devel@lists.sourceforge.net";
  20. #include "common.h"
  21. #include "netutils.h"
  22. #include "utils.h"
  23. #ifdef HAVE_SSL
  24. static int check_cert = FALSE;
  25. static int days_till_exp;
  26. # define my_recv(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
  27. # define my_send(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
  28. #else
  29. # define my_recv(buf, len) read(sd, buf, len)
  30. # define my_send(buf, len) send(sd, buf, len, 0)
  31. #endif
  32. /* int my_recv(char *, size_t); */
  33. static int process_arguments (int, char **);
  34. void print_help (void);
  35. void print_usage (void);
  36. #define EXPECT server_expect[0]
  37. static char *SERVICE = "TCP";
  38. static char *SEND = NULL;
  39. static char *QUIT = NULL;
  40. static int PROTOCOL = IPPROTO_TCP; /* most common is default */
  41. static int PORT = 0;
  42. static int server_port = 0;
  43. static char *server_address = NULL;
  44. static char *server_send = NULL;
  45. static char *server_quit = NULL;
  46. static char **server_expect;
  47. static size_t server_expect_count = 0;
  48. static size_t maxbytes = 0;
  49. static char **warn_codes = NULL;
  50. static size_t warn_codes_count = 0;
  51. static char **crit_codes = NULL;
  52. static size_t crit_codes_count = 0;
  53. static unsigned int delay = 0;
  54. static double warning_time = 0;
  55. static double critical_time = 0;
  56. static double elapsed_time = 0;
  57. static long microsec;
  58. static int sd = 0;
  59. #define MAXBUF 1024
  60. static char buffer[MAXBUF];
  61. static int expect_mismatch_state = STATE_WARNING;
  62. #define FLAG_SSL 0x01
  63. #define FLAG_VERBOSE 0x02
  64. #define FLAG_EXACT_MATCH 0x04
  65. #define FLAG_TIME_WARN 0x08
  66. #define FLAG_TIME_CRIT 0x10
  67. #define FLAG_HIDE_OUTPUT 0x20
  68. static size_t flags = FLAG_EXACT_MATCH;
  69. int
  70. main (int argc, char **argv)
  71. {
  72. int result = STATE_UNKNOWN;
  73. int i;
  74. char *status = NULL;
  75. struct timeval tv;
  76. size_t len, match = -1;
  77. setlocale (LC_ALL, "");
  78. bindtextdomain (PACKAGE, LOCALEDIR);
  79. textdomain (PACKAGE);
  80. /* determine program- and service-name quickly */
  81. progname = strrchr(argv[0], '/');
  82. if(progname != NULL) progname++;
  83. else progname = argv[0];
  84. len = strlen(progname);
  85. if(len > 6 && !memcmp(progname, "check_", 6)) {
  86. SERVICE = progname + 6;
  87. for(i = 0; i < len - 6; i++)
  88. SERVICE[i] = toupper(SERVICE[i]);
  89. }
  90. /* set up a resonable buffer at first (will be realloc()'ed if
  91. * user specifies other options) */
  92. server_expect = calloc(sizeof(char *), 2);
  93. /* determine defaults for this service's protocol */
  94. if (!strncmp(SERVICE, "UDP", 3)) {
  95. PROTOCOL = IPPROTO_UDP;
  96. }
  97. else if (!strncmp(SERVICE, "FTP", 3)) {
  98. EXPECT = "220";
  99. QUIT = "QUIT\r\n";
  100. PORT = 21;
  101. }
  102. else if (!strncmp(SERVICE, "POP", 3) || !strncmp(SERVICE, "POP3", 4)) {
  103. EXPECT = "+OK";
  104. QUIT = "QUIT\r\n";
  105. PORT = 110;
  106. }
  107. else if (!strncmp(SERVICE, "SMTP", 4)) {
  108. EXPECT = "220";
  109. QUIT = "QUIT\r\n";
  110. PORT = 25;
  111. }
  112. else if (!strncmp(SERVICE, "IMAP", 4)) {
  113. EXPECT = "* OK";
  114. QUIT = "a1 LOGOUT\r\n";
  115. PORT = 143;
  116. }
  117. #ifdef HAVE_SSL
  118. else if (!strncmp(SERVICE, "SIMAP", 5)) {
  119. EXPECT = "* OK";
  120. QUIT = "a1 LOGOUT\r\n";
  121. flags |= FLAG_SSL;
  122. PORT = 993;
  123. }
  124. else if (!strncmp(SERVICE, "SPOP", 4)) {
  125. EXPECT = "+OK";
  126. QUIT = "QUIT\r\n";
  127. flags |= FLAG_SSL;
  128. PORT = 995;
  129. }
  130. else if (!strncmp(SERVICE, "SSMTP", 5)) {
  131. EXPECT = "220";
  132. QUIT = "QUIT\r\n";
  133. flags |= FLAG_SSL;
  134. PORT = 465;
  135. }
  136. else if (!strncmp(SERVICE, "JABBER", 6)) {
  137. SEND = "<stream:stream to=\'host\' xmlns=\'jabber:client\' xmlns:stream=\'http://etherx.jabber.org/streams\'>\n";
  138. EXPECT = "<?xml version=\'1.0\'?><stream:stream xmlns:stream=\'http://etherx.jabber.org/streams\'";
  139. QUIT = "</stream:stream>\n";
  140. flags |= FLAG_SSL | FLAG_HIDE_OUTPUT;
  141. PORT = 5222;
  142. }
  143. else if (!strncmp (SERVICE, "NNTPS", 5)) {
  144. server_expect_count = 2;
  145. server_expect[0] = "200";
  146. server_expect[1] = "201";
  147. QUIT = "QUIT\r\n";
  148. flags |= FLAG_SSL;
  149. PORT = 563;
  150. }
  151. #endif
  152. else if (!strncmp (SERVICE, "NNTP", 4)) {
  153. server_expect_count = 2;
  154. server_expect = malloc(sizeof(char *) * server_expect_count);
  155. server_expect[0] = strdup("200");
  156. server_expect[1] = strdup("201");
  157. QUIT = "QUIT\r\n";
  158. PORT = 119;
  159. }
  160. else if (!strncmp(SERVICE, "CLAMD", 5)) {
  161. SEND = "PING";
  162. EXPECT = "PONG";
  163. QUIT = NULL;
  164. PORT = 3310;
  165. }
  166. /* fallthrough check, so it's supposed to use reverse matching */
  167. else if (strcmp (SERVICE, "TCP"))
  168. usage (_("CRITICAL - Generic check_tcp called with unknown service\n"));
  169. server_address = "127.0.0.1";
  170. server_port = PORT;
  171. server_send = SEND;
  172. server_quit = QUIT;
  173. status = NULL;
  174. if (process_arguments (argc, argv) == ERROR)
  175. usage4 (_("Could not parse arguments"));
  176. if(flags & FLAG_VERBOSE) {
  177. printf("Using service %s\n", SERVICE);
  178. printf("Port: %d\n", server_port);
  179. printf("flags: 0x%x\n", (int)flags);
  180. }
  181. if(EXPECT && !server_expect_count)
  182. server_expect_count++;
  183. if(PROTOCOL==IPPROTO_UDP && !(server_expect_count && server_send)){
  184. usage(_("With UDP checks, a send/expect string must be specified."));
  185. }
  186. /* set up the timer */
  187. signal (SIGALRM, socket_timeout_alarm_handler);
  188. alarm (socket_timeout);
  189. /* try to connect to the host at the given port number */
  190. gettimeofday (&tv, NULL);
  191. result = np_net_connect (server_address, server_port, &sd, PROTOCOL);
  192. if (result == STATE_CRITICAL) return STATE_CRITICAL;
  193. #ifdef HAVE_SSL
  194. if (flags & FLAG_SSL){
  195. result = np_net_ssl_init(sd);
  196. if (result == STATE_OK && check_cert == TRUE) {
  197. result = np_net_ssl_check_cert(days_till_exp);
  198. if(result != STATE_OK) {
  199. printf(_("CRITICAL - Cannot retrieve server certificate.\n"));
  200. }
  201. }
  202. }
  203. if(result != STATE_OK){
  204. np_net_ssl_cleanup();
  205. if(sd) close(sd);
  206. return result;
  207. }
  208. #endif /* HAVE_SSL */
  209. if (server_send != NULL) { /* Something to send? */
  210. my_send(server_send, strlen(server_send));
  211. }
  212. if (delay > 0) {
  213. tv.tv_sec += delay;
  214. sleep (delay);
  215. }
  216. if(flags & FLAG_VERBOSE) {
  217. if (server_send) {
  218. printf("Send string: %s\n", server_send);
  219. }
  220. if (server_quit) {
  221. printf("Quit string: %s\n", server_quit);
  222. }
  223. printf("server_expect_count: %d\n", (int)server_expect_count);
  224. for(i = 0; i < server_expect_count; i++)
  225. printf("\t%d: %s\n", i, server_expect[i]);
  226. }
  227. /* if(len) later on, we know we have a non-NULL response */
  228. len = 0;
  229. if (server_expect_count) {
  230. /* watch for the expect string */
  231. while ((i = my_recv(buffer, sizeof(buffer))) > 0) {
  232. status = realloc(status, len + i + 1);
  233. memcpy(&status[len], buffer, i);
  234. len += i;
  235. /* stop reading if user-forced or data-starved */
  236. if(i < sizeof(buffer) || (maxbytes && len >= maxbytes))
  237. break;
  238. if (maxbytes && len >= maxbytes)
  239. break;
  240. }
  241. /* no data when expected, so return critical */
  242. if (len == 0)
  243. die (STATE_CRITICAL, _("No data received from host\n"));
  244. /* force null-termination and strip whitespace from end of output */
  245. status[len--] = '\0';
  246. /* print raw output if we're debugging */
  247. if(flags & FLAG_VERBOSE)
  248. printf("received %d bytes from host\n#-raw-recv-------#\n%s\n#-raw-recv-------#\n",
  249. (int)len + 1, status);
  250. while(isspace(status[len])) status[len--] = '\0';
  251. for (i = 0; i < server_expect_count; i++) {
  252. match = -2; /* tag it so we know if we tried and failed */
  253. if (flags & FLAG_VERBOSE)
  254. printf ("looking for [%s] %s [%s]\n", server_expect[i],
  255. (flags & FLAG_EXACT_MATCH) ? "in beginning of" : "anywhere in",
  256. status);
  257. /* match it. math first in short-circuit */
  258. if ((flags & FLAG_EXACT_MATCH && !strncmp(status, server_expect[i], strlen(server_expect[i]))) ||
  259. (!(flags & FLAG_EXACT_MATCH) && strstr(status, server_expect[i])))
  260. {
  261. if(flags & FLAG_VERBOSE) puts("found it");
  262. match = i;
  263. break;
  264. }
  265. }
  266. }
  267. if (server_quit != NULL) {
  268. my_send(server_quit, strlen(server_quit));
  269. }
  270. #ifdef HAVE_SSL
  271. np_net_ssl_cleanup();
  272. #endif
  273. if (sd) close (sd);
  274. microsec = deltime (tv);
  275. elapsed_time = (double)microsec / 1.0e6;
  276. if (flags & FLAG_TIME_CRIT && elapsed_time > critical_time)
  277. result = STATE_CRITICAL;
  278. else if (flags & FLAG_TIME_WARN && elapsed_time > warning_time)
  279. result = STATE_WARNING;
  280. /* did we get the response we hoped? */
  281. if(match == -2 && result != STATE_CRITICAL)
  282. result = expect_mismatch_state;
  283. /* reset the alarm */
  284. alarm (0);
  285. /* this is a bit stupid, because we don't want to print the
  286. * response time (which can look ok to the user) if we didn't get
  287. * the response we were looking for. if-else */
  288. printf(_("%s %s - "), SERVICE, state_text(result));
  289. if(match == -2 && len && !(flags & FLAG_HIDE_OUTPUT))
  290. printf("Unexpected response from host/socket: %s", status);
  291. else {
  292. printf("%.3f second response time on ", elapsed_time);
  293. if(server_address[0] != '/')
  294. printf("port %d", server_port);
  295. else
  296. printf("socket %s", server_address);
  297. }
  298. if (match != -2 && !(flags & FLAG_HIDE_OUTPUT) && len)
  299. printf (" [%s]", status);
  300. /* perf-data doesn't apply when server doesn't talk properly,
  301. * so print all zeroes on warn and crit */
  302. if(match == -2)
  303. printf ("|time=%fs;0.0;0.0;0.0;0.0", elapsed_time);
  304. else
  305. printf("|%s",
  306. fperfdata ("time", elapsed_time, "s",
  307. TRUE, warning_time,
  308. TRUE, critical_time,
  309. TRUE, 0,
  310. TRUE, socket_timeout)
  311. );
  312. putchar('\n');
  313. return result;
  314. }
  315. /* process command-line arguments */
  316. static int
  317. process_arguments (int argc, char **argv)
  318. {
  319. int c;
  320. int escape = 0;
  321. int option = 0;
  322. static struct option longopts[] = {
  323. {"hostname", required_argument, 0, 'H'},
  324. {"critical-time", required_argument, 0, 'c'},
  325. {"warning-time", required_argument, 0, 'w'},
  326. {"critical-codes", required_argument, 0, 'C'},
  327. {"warning-codes", required_argument, 0, 'W'},
  328. {"timeout", required_argument, 0, 't'},
  329. {"protocol", required_argument, 0, 'P'},
  330. {"port", required_argument, 0, 'p'},
  331. {"escape", required_argument, 0, 'E'},
  332. {"send", required_argument, 0, 's'},
  333. {"expect", required_argument, 0, 'e'},
  334. {"maxbytes", required_argument, 0, 'm'},
  335. {"quit", required_argument, 0, 'q'},
  336. {"jail", required_argument, 0, 'j'},
  337. {"delay", required_argument, 0, 'd'},
  338. {"refuse", required_argument, 0, 'r'},
  339. {"mismatch", required_argument, 0, 'M'},
  340. {"use-ipv4", no_argument, 0, '4'},
  341. {"use-ipv6", no_argument, 0, '6'},
  342. {"verbose", no_argument, 0, 'v'},
  343. {"version", no_argument, 0, 'V'},
  344. {"help", no_argument, 0, 'h'},
  345. #ifdef HAVE_SSL
  346. {"ssl", no_argument, 0, 'S'},
  347. {"certificate", required_argument, 0, 'D'},
  348. #endif
  349. {0, 0, 0, 0}
  350. };
  351. if (argc < 2)
  352. usage4 (_("No arguments found"));
  353. /* backwards compatibility */
  354. for (c = 1; c < argc; c++) {
  355. if (strcmp ("-to", argv[c]) == 0)
  356. strcpy (argv[c], "-t");
  357. else if (strcmp ("-wt", argv[c]) == 0)
  358. strcpy (argv[c], "-w");
  359. else if (strcmp ("-ct", argv[c]) == 0)
  360. strcpy (argv[c], "-c");
  361. }
  362. if (!is_option (argv[1])) {
  363. server_address = argv[1];
  364. argv[1] = argv[0];
  365. argv = &argv[1];
  366. argc--;
  367. }
  368. while (1) {
  369. c = getopt_long (argc, argv, "+hVv46EH:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:",
  370. longopts, &option);
  371. if (c == -1 || c == EOF || c == 1)
  372. break;
  373. switch (c) {
  374. case '?': /* print short usage statement if args not parsable */
  375. usage2 (_("Unknown argument"), optarg);
  376. case 'h': /* help */
  377. print_help ();
  378. exit (STATE_OK);
  379. case 'V': /* version */
  380. print_revision (progname, revision);
  381. exit (STATE_OK);
  382. case 'v': /* verbose mode */
  383. flags |= FLAG_VERBOSE;
  384. break;
  385. case '4':
  386. address_family = AF_INET;
  387. break;
  388. case '6':
  389. #ifdef USE_IPV6
  390. address_family = AF_INET6;
  391. #else
  392. usage4 (_("IPv6 support not available"));
  393. #endif
  394. break;
  395. case 'H': /* hostname */
  396. server_address = optarg;
  397. break;
  398. case 'c': /* critical */
  399. if (!is_intnonneg (optarg))
  400. usage4 (_("Critical threshold must be a positive integer"));
  401. else
  402. critical_time = strtod (optarg, NULL);
  403. flags |= FLAG_TIME_CRIT;
  404. break;
  405. case 'j': /* hide output */
  406. flags |= FLAG_HIDE_OUTPUT;
  407. break;
  408. case 'w': /* warning */
  409. if (!is_intnonneg (optarg))
  410. usage4 (_("Warning threshold must be a positive integer"));
  411. else
  412. warning_time = strtod (optarg, NULL);
  413. flags |= FLAG_TIME_WARN;
  414. break;
  415. case 'C':
  416. crit_codes = realloc (crit_codes, ++crit_codes_count);
  417. crit_codes[crit_codes_count - 1] = optarg;
  418. break;
  419. case 'W':
  420. warn_codes = realloc (warn_codes, ++warn_codes_count);
  421. warn_codes[warn_codes_count - 1] = optarg;
  422. break;
  423. case 't': /* timeout */
  424. if (!is_intpos (optarg))
  425. usage4 (_("Timeout interval must be a positive integer"));
  426. else
  427. socket_timeout = atoi (optarg);
  428. break;
  429. case 'p': /* port */
  430. if (!is_intpos (optarg))
  431. usage4 (_("Port must be a positive integer"));
  432. else
  433. server_port = atoi (optarg);
  434. break;
  435. case 'E':
  436. escape = 1;
  437. break;
  438. case 's':
  439. if (escape)
  440. server_send = np_escaped_string(optarg);
  441. else
  442. asprintf(&server_send, "%s", optarg);
  443. break;
  444. case 'e': /* expect string (may be repeated) */
  445. EXPECT = NULL;
  446. flags &= ~FLAG_EXACT_MATCH;
  447. if (server_expect_count == 0)
  448. server_expect = malloc (sizeof (char *) * (++server_expect_count));
  449. else
  450. server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count));
  451. server_expect[server_expect_count - 1] = optarg;
  452. break;
  453. case 'm':
  454. if (!is_intpos (optarg))
  455. usage4 (_("Maxbytes must be a positive integer"));
  456. else
  457. maxbytes = strtol (optarg, NULL, 0);
  458. case 'q':
  459. if (escape)
  460. server_quit = np_escaped_string(optarg);
  461. else
  462. asprintf(&server_quit, "%s\r\n", optarg);
  463. break;
  464. case 'r':
  465. if (!strncmp(optarg,"ok",2))
  466. econn_refuse_state = STATE_OK;
  467. else if (!strncmp(optarg,"warn",4))
  468. econn_refuse_state = STATE_WARNING;
  469. else if (!strncmp(optarg,"crit",4))
  470. econn_refuse_state = STATE_CRITICAL;
  471. else
  472. usage4 (_("Refuse must be one of ok, warn, crit"));
  473. break;
  474. case 'M':
  475. if (!strncmp(optarg,"ok",2))
  476. expect_mismatch_state = STATE_OK;
  477. else if (!strncmp(optarg,"warn",4))
  478. expect_mismatch_state = STATE_WARNING;
  479. else if (!strncmp(optarg,"crit",4))
  480. expect_mismatch_state = STATE_CRITICAL;
  481. else
  482. usage4 (_("Mismatch must be one of ok, warn, crit"));
  483. break;
  484. case 'd':
  485. if (is_intpos (optarg))
  486. delay = atoi (optarg);
  487. else
  488. usage4 (_("Delay must be a positive integer"));
  489. break;
  490. case 'D': /* Check SSL cert validity - days 'til certificate expiration */
  491. #ifdef HAVE_SSL
  492. # ifdef USE_OPENSSL /* XXX */
  493. if (!is_intnonneg (optarg))
  494. usage2 (_("Invalid certificate expiration period"), optarg);
  495. days_till_exp = atoi (optarg);
  496. check_cert = TRUE;
  497. flags |= FLAG_SSL;
  498. break;
  499. # endif /* USE_OPENSSL */
  500. #endif
  501. /* fallthrough if we don't have ssl */
  502. case 'S':
  503. #ifdef HAVE_SSL
  504. flags |= FLAG_SSL;
  505. #else
  506. die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
  507. #endif
  508. break;
  509. }
  510. }
  511. if (server_address == NULL)
  512. usage4 (_("You must provide a server address"));
  513. else if (server_address[0] != '/' && is_host (server_address) == FALSE)
  514. die (STATE_CRITICAL, "%s: %s - %s\n", progname, _("Invalid hostname, address or socket"), server_address);
  515. return TRUE;
  516. }
  517. void
  518. print_help (void)
  519. {
  520. print_revision (progname, revision);
  521. printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
  522. printf (COPYRIGHT, copyright, email);
  523. printf (_("This plugin tests %s connections with the specified host (or unix socket).\n\n"),
  524. SERVICE);
  525. print_usage ();
  526. printf (_(UT_HELP_VRSN));
  527. printf (_(UT_HOST_PORT), 'p', "none");
  528. printf (_(UT_IPv46));
  529. printf (_("\
  530. -E, --escape\n\
  531. Can use \\n, \\r, \\t or \\ in send or quit string.\n\
  532. Default: nothing added to send, \\r\\n added to end of quit\n\
  533. -s, --send=STRING\n\
  534. String to send to the server\n\
  535. -e, --expect=STRING\n\
  536. String to expect in server response\n\
  537. -q, --quit=STRING\n\
  538. String to send server to initiate a clean close of the connection\n"));
  539. printf (_("\
  540. -r, --refuse=ok|warn|crit\n\
  541. Accept tcp refusals with states ok, warn, crit (default: crit)\n\
  542. -M, --mismatch=ok|warn|crit\n\
  543. Accept expected string mismatches with states ok, warn, crit (default: warn)\n\
  544. -j, --jail\n\
  545. Hide output from TCP socket\n\
  546. -m, --maxbytes=INTEGER\n\
  547. Close connection once more than this number of bytes are received\n\
  548. -d, --delay=INTEGER\n\
  549. Seconds to wait between sending string and polling for response\n"));
  550. #ifdef HAVE_SSL
  551. printf (_("\
  552. -D, --certificate=INTEGER\n\
  553. Minimum number of days a certificate has to be valid.\n\
  554. -S, --ssl\n\
  555. Use SSL for the connection.\n"));
  556. #endif
  557. printf (_(UT_WARN_CRIT));
  558. printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
  559. printf (_(UT_VERBOSE));
  560. printf (_(UT_SUPPORT));
  561. }
  562. void
  563. print_usage (void)
  564. {
  565. printf ("\
  566. Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
  567. [-s <send string>] [-e <expect string>] [-q <quit string>]\n\
  568. [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\
  569. [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]\n\
  570. [-D <days to cert expiry>] [-S <use SSL>] [-E]\n", progname);
  571. }