Code

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