Back to index

nagios-plugins  1.4.16
check_tcp.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002 * 
00003 * Nagios check_tcp plugin
00004 * 
00005 * License: GPL
00006 * Copyright (c) 1999-2008 Nagios Plugins Development Team
00007 * 
00008 * Description:
00009 * 
00010 * This file contains the check_tcp plugin
00011 * 
00012 * 
00013 * This program is free software: you can redistribute it and/or modify
00014 * it under the terms of the GNU General Public License as published by
00015 * the Free Software Foundation, either version 3 of the License, or
00016 * (at your option) any later version.
00017 * 
00018 * This program is distributed in the hope that it will be useful,
00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 * GNU General Public License for more details.
00022 * 
00023 * You should have received a copy of the GNU General Public License
00024 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025 *
00026 * $Id$
00027 * 
00028 *****************************************************************************/
00029 
00030 /* progname "check_tcp" changes depending on symlink called */
00031 char *progname;
00032 const char *copyright = "1999-2008";
00033 const char *email = "nagiosplug-devel@lists.sourceforge.net";
00034 
00035 #include "common.h"
00036 #include "netutils.h"
00037 #include "utils.h"
00038 #include "utils_tcp.h"
00039 
00040 #ifdef HAVE_SSL
00041 static int check_cert = FALSE;
00042 static int days_till_exp_warn, days_till_exp_crit;
00043 # define my_recv(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
00044 # define my_send(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
00045 #else
00046 # define my_recv(buf, len) read(sd, buf, len)
00047 # define my_send(buf, len) send(sd, buf, len, 0)
00048 #endif
00049 
00050 /* int my_recv(char *, size_t); */
00051 static int process_arguments (int, char **);
00052 void print_help (void);
00053 void print_usage (void);
00054 
00055 #define EXPECT server_expect[0]
00056 static char *SERVICE = "TCP";
00057 static char *SEND = NULL;
00058 static char *QUIT = NULL;
00059 static int PROTOCOL = IPPROTO_TCP; /* most common is default */
00060 static int PORT = 0;
00061 
00062 static int server_port = 0;
00063 static char *server_address = NULL;
00064 static char *server_send = NULL;
00065 static char *server_quit = NULL;
00066 static char **server_expect;
00067 static size_t server_expect_count = 0;
00068 static size_t maxbytes = 0;
00069 static char **warn_codes = NULL;
00070 static size_t warn_codes_count = 0;
00071 static char **crit_codes = NULL;
00072 static size_t crit_codes_count = 0;
00073 static unsigned int delay = 0;
00074 static double warning_time = 0;
00075 static double critical_time = 0;
00076 static double elapsed_time = 0;
00077 static long microsec;
00078 static int sd = 0;
00079 #define MAXBUF 1024
00080 static char buffer[MAXBUF];
00081 static int expect_mismatch_state = STATE_WARNING;
00082 
00083 #define FLAG_SSL 0x01
00084 #define FLAG_VERBOSE 0x02
00085 #define FLAG_EXACT_MATCH 0x04
00086 #define FLAG_TIME_WARN 0x08
00087 #define FLAG_TIME_CRIT 0x10
00088 #define FLAG_HIDE_OUTPUT 0x20
00089 #define FLAG_MATCH_ALL 0x40
00090 static size_t flags = FLAG_EXACT_MATCH;
00091 
00092 int
00093 main (int argc, char **argv)
00094 {
00095        int result = STATE_UNKNOWN;
00096        int i;
00097        char *status = NULL;
00098        struct timeval tv;
00099        size_t len;
00100        int match = -1;
00101 
00102        setlocale (LC_ALL, "");
00103        bindtextdomain (PACKAGE, LOCALEDIR);
00104        textdomain (PACKAGE);
00105 
00106        /* determine program- and service-name quickly */
00107        progname = strrchr(argv[0], '/');
00108        if(progname != NULL) progname++;
00109        else progname = argv[0];
00110 
00111        len = strlen(progname);
00112        if(len > 6 && !memcmp(progname, "check_", 6)) {
00113               SERVICE = strdup(progname + 6);
00114               for(i = 0; i < len - 6; i++)
00115                      SERVICE[i] = toupper(SERVICE[i]);
00116        }
00117 
00118        /* set up a resonable buffer at first (will be realloc()'ed if
00119         * user specifies other options) */
00120        server_expect = calloc(sizeof(char *), 2);
00121 
00122        /* determine defaults for this service's protocol */
00123        if (!strncmp(SERVICE, "UDP", 3)) {
00124               PROTOCOL = IPPROTO_UDP;
00125        }
00126        else if (!strncmp(SERVICE, "FTP", 3)) {
00127               EXPECT = "220";
00128               QUIT = "QUIT\r\n";
00129               PORT = 21;
00130        }
00131        else if (!strncmp(SERVICE, "POP", 3) || !strncmp(SERVICE, "POP3", 4)) {
00132               EXPECT = "+OK";
00133               QUIT = "QUIT\r\n";
00134               PORT = 110;
00135        }
00136        else if (!strncmp(SERVICE, "SMTP", 4)) {
00137               EXPECT = "220";
00138               QUIT = "QUIT\r\n";
00139               PORT = 25;
00140        }
00141        else if (!strncmp(SERVICE, "IMAP", 4)) {
00142               EXPECT = "* OK";
00143               QUIT = "a1 LOGOUT\r\n";
00144               PORT = 143;
00145        }
00146 #ifdef HAVE_SSL
00147        else if (!strncmp(SERVICE, "SIMAP", 5)) {
00148               EXPECT = "* OK";
00149               QUIT = "a1 LOGOUT\r\n";
00150               flags |= FLAG_SSL;
00151               PORT = 993;
00152        }
00153        else if (!strncmp(SERVICE, "SPOP", 4)) {
00154               EXPECT = "+OK";
00155               QUIT = "QUIT\r\n";
00156               flags |= FLAG_SSL;
00157               PORT = 995;
00158        }
00159        else if (!strncmp(SERVICE, "SSMTP", 5)) {
00160               EXPECT = "220";
00161               QUIT = "QUIT\r\n";
00162               flags |= FLAG_SSL;
00163               PORT = 465;
00164        }
00165        else if (!strncmp(SERVICE, "JABBER", 6)) {
00166               SEND = "<stream:stream to=\'host\' xmlns=\'jabber:client\' xmlns:stream=\'http://etherx.jabber.org/streams\'>\n";
00167               EXPECT = "<?xml version=\'1.0\'?><stream:stream xmlns=\'jabber:client\' xmlns:stream=\'http://etherx.jabber.org/streams\'";
00168               QUIT = "</stream:stream>\n";
00169               flags |= FLAG_HIDE_OUTPUT;
00170               PORT = 5222;
00171        }
00172        else if (!strncmp (SERVICE, "NNTPS", 5)) {
00173               server_expect_count = 2;
00174               server_expect[0] = "200";
00175               server_expect[1] = "201";
00176               QUIT = "QUIT\r\n";
00177               flags |= FLAG_SSL;
00178               PORT = 563;
00179        }
00180 #endif
00181        else if (!strncmp (SERVICE, "NNTP", 4)) {
00182               server_expect_count = 2;
00183               server_expect = malloc(sizeof(char *) * server_expect_count);
00184               server_expect[0] = strdup("200");
00185               server_expect[1] = strdup("201");
00186               QUIT = "QUIT\r\n";
00187               PORT = 119;
00188        }
00189        else if (!strncmp(SERVICE, "CLAMD", 5)) {
00190               SEND = "PING";
00191               EXPECT = "PONG";
00192               QUIT = NULL;
00193               PORT = 3310;
00194        }
00195        /* fallthrough check, so it's supposed to use reverse matching */
00196        else if (strcmp (SERVICE, "TCP"))
00197               usage (_("CRITICAL - Generic check_tcp called with unknown service\n"));
00198 
00199        server_address = "127.0.0.1";
00200        server_port = PORT;
00201        server_send = SEND;
00202        server_quit = QUIT;
00203        status = NULL;
00204 
00205        /* Parse extra opts if any */
00206        argv=np_extra_opts (&argc, argv, progname);
00207 
00208        if (process_arguments (argc, argv) == ERROR)
00209               usage4 (_("Could not parse arguments"));
00210 
00211        if(flags & FLAG_VERBOSE) {
00212               printf("Using service %s\n", SERVICE);
00213               printf("Port: %d\n", server_port);
00214               printf("flags: 0x%x\n", (int)flags);
00215        }
00216 
00217        if(EXPECT && !server_expect_count)
00218               server_expect_count++;
00219 
00220        if(PROTOCOL==IPPROTO_UDP && !(server_expect_count && server_send)){
00221               usage(_("With UDP checks, a send/expect string must be specified."));
00222        }
00223 
00224        /* set up the timer */
00225        signal (SIGALRM, socket_timeout_alarm_handler);
00226        alarm (socket_timeout);
00227 
00228        /* try to connect to the host at the given port number */
00229        gettimeofday (&tv, NULL);
00230 
00231        result = np_net_connect (server_address, server_port, &sd, PROTOCOL);
00232        if (result == STATE_CRITICAL) return STATE_CRITICAL;
00233 
00234 #ifdef HAVE_SSL
00235        if (flags & FLAG_SSL){
00236               result = np_net_ssl_init(sd);
00237               if (result == STATE_OK && check_cert == TRUE) {
00238                      result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
00239               }
00240        }
00241        if(result != STATE_OK){
00242               np_net_ssl_cleanup();
00243               if(sd) close(sd);
00244               return result;
00245        }
00246 #endif /* HAVE_SSL */
00247 
00248        if (server_send != NULL) {         /* Something to send? */
00249               my_send(server_send, strlen(server_send));
00250        }
00251 
00252        if (delay > 0) {
00253               tv.tv_sec += delay;
00254               sleep (delay);
00255        }
00256 
00257        if(flags & FLAG_VERBOSE) {
00258               if (server_send) {
00259                      printf("Send string: %s\n", server_send);
00260               }
00261               if (server_quit) {
00262                      printf("Quit string: %s\n", server_quit);
00263               }
00264               printf("server_expect_count: %d\n", (int)server_expect_count);
00265               for(i = 0; i < server_expect_count; i++)
00266                      printf("\t%d: %s\n", i, server_expect[i]);
00267        }
00268 
00269        /* if(len) later on, we know we have a non-NULL response */
00270        len = 0;
00271        if (server_expect_count) {
00272 
00273               /* watch for the expect string */
00274               while ((i = my_recv(buffer, sizeof(buffer))) > 0) {
00275                      status = realloc(status, len + i + 1);
00276                      memcpy(&status[len], buffer, i);
00277                      len += i;
00278 
00279                      /* stop reading if user-forced or data-starved */
00280                      if(i < sizeof(buffer) || (maxbytes && len >= maxbytes))
00281                             break;
00282 
00283                      if (maxbytes && len >= maxbytes)
00284                             break;
00285               }
00286 
00287               /* no data when expected, so return critical */
00288               if (len == 0)
00289                      die (STATE_CRITICAL, _("No data received from host\n"));
00290 
00291               /* force null-termination and strip whitespace from end of output */
00292               status[len--] = '\0';
00293               /* print raw output if we're debugging */
00294               if(flags & FLAG_VERBOSE)
00295                      printf("received %d bytes from host\n#-raw-recv-------#\n%s\n#-raw-recv-------#\n",
00296                             (int)len + 1, status);
00297               while(isspace(status[len])) status[len--] = '\0';
00298 
00299               match = np_expect_match(status,
00300                                 server_expect,
00301                                 server_expect_count,
00302                                 (flags & FLAG_MATCH_ALL ? TRUE : FALSE),
00303                                 (flags & FLAG_EXACT_MATCH ? TRUE : FALSE),
00304                                 (flags & FLAG_VERBOSE ? TRUE : FALSE));
00305        }
00306 
00307        if (server_quit != NULL) {
00308               my_send(server_quit, strlen(server_quit));
00309        }
00310 #ifdef HAVE_SSL
00311        np_net_ssl_cleanup();
00312 #endif
00313        if (sd) close (sd);
00314 
00315        microsec = deltime (tv);
00316        elapsed_time = (double)microsec / 1.0e6;
00317 
00318        if (flags & FLAG_TIME_CRIT && elapsed_time > critical_time)
00319               result = STATE_CRITICAL;
00320        else if (flags & FLAG_TIME_WARN && elapsed_time > warning_time)
00321               result = STATE_WARNING;
00322 
00323        /* did we get the response we hoped? */
00324        if(match == FALSE && result != STATE_CRITICAL)
00325               result = expect_mismatch_state;
00326 
00327        /* reset the alarm */
00328        alarm (0);
00329 
00330        /* this is a bit stupid, because we don't want to print the
00331         * response time (which can look ok to the user) if we didn't get
00332         * the response we were looking for. if-else */
00333        printf("%s %s - ", SERVICE, state_text(result));
00334 
00335        if(match == FALSE && len && !(flags & FLAG_HIDE_OUTPUT))
00336               printf("Unexpected response from host/socket: %s", status);
00337        else {
00338               if(match == FALSE)
00339                      printf("Unexpected response from host/socket on ");
00340               else
00341                      printf("%.3f second response time on ", elapsed_time);
00342               if(server_address[0] != '/')
00343                      printf("port %d", server_port);
00344               else
00345                      printf("socket %s", server_address);
00346        }
00347 
00348        if (match != FALSE && !(flags & FLAG_HIDE_OUTPUT) && len)
00349               printf (" [%s]", status);
00350 
00351        /* perf-data doesn't apply when server doesn't talk properly,
00352         * so print all zeroes on warn and crit. Use fperfdata since
00353         * localisation settings can make different outputs */
00354        if(match == FALSE)
00355               printf ("|%s",
00356                             fperfdata ("time", elapsed_time, "s",
00357                             (flags & FLAG_TIME_WARN ? TRUE : FALSE), 0,
00358                             (flags & FLAG_TIME_CRIT ? TRUE : FALSE), 0,
00359                             TRUE, 0,
00360                             TRUE, socket_timeout)
00361                      );
00362        else
00363               printf("|%s",
00364                             fperfdata ("time", elapsed_time, "s",
00365                             (flags & FLAG_TIME_WARN ? TRUE : FALSE), warning_time,
00366                             (flags & FLAG_TIME_CRIT ? TRUE : FALSE), critical_time,
00367                             TRUE, 0,
00368                             TRUE, socket_timeout)
00369                      );
00370 
00371        putchar('\n');
00372        return result;
00373 }
00374 
00375 
00376 
00377 /* process command-line arguments */
00378 static int
00379 process_arguments (int argc, char **argv)
00380 {
00381        int c;
00382        int escape = 0;
00383        char *temp;
00384 
00385        int option = 0;
00386        static struct option longopts[] = {
00387               {"hostname", required_argument, 0, 'H'},
00388               {"critical", required_argument, 0, 'c'},
00389               {"warning", required_argument, 0, 'w'},
00390               {"critical-codes", required_argument, 0, 'C'},
00391               {"warning-codes", required_argument, 0, 'W'},
00392               {"timeout", required_argument, 0, 't'},
00393               {"protocol", required_argument, 0, 'P'}, /* FIXME: Unhandled */
00394               {"port", required_argument, 0, 'p'},
00395               {"escape", no_argument, 0, 'E'},
00396               {"all", no_argument, 0, 'A'},
00397               {"send", required_argument, 0, 's'},
00398               {"expect", required_argument, 0, 'e'},
00399               {"maxbytes", required_argument, 0, 'm'},
00400               {"quit", required_argument, 0, 'q'},
00401               {"jail", no_argument, 0, 'j'},
00402               {"delay", required_argument, 0, 'd'},
00403               {"refuse", required_argument, 0, 'r'},
00404               {"mismatch", required_argument, 0, 'M'},
00405               {"use-ipv4", no_argument, 0, '4'},
00406               {"use-ipv6", no_argument, 0, '6'},
00407               {"verbose", no_argument, 0, 'v'},
00408               {"version", no_argument, 0, 'V'},
00409               {"help", no_argument, 0, 'h'},
00410               {"ssl", no_argument, 0, 'S'},
00411               {"certificate", required_argument, 0, 'D'},
00412               {0, 0, 0, 0}
00413        };
00414 
00415        if (argc < 2)
00416               usage4 (_("No arguments found"));
00417 
00418        /* backwards compatibility */
00419        for (c = 1; c < argc; c++) {
00420               if (strcmp ("-to", argv[c]) == 0)
00421                      strcpy (argv[c], "-t");
00422               else if (strcmp ("-wt", argv[c]) == 0)
00423                      strcpy (argv[c], "-w");
00424               else if (strcmp ("-ct", argv[c]) == 0)
00425                      strcpy (argv[c], "-c");
00426        }
00427 
00428        if (!is_option (argv[1])) {
00429               server_address = argv[1];
00430               argv[1] = argv[0];
00431               argv = &argv[1];
00432               argc--;
00433        }
00434 
00435        while (1) {
00436               c = getopt_long (argc, argv, "+hVv46EAH:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:",
00437                                longopts, &option);
00438 
00439               if (c == -1 || c == EOF || c == 1)
00440                      break;
00441 
00442               switch (c) {
00443               case '?':                 /* print short usage statement if args not parsable */
00444                      usage5 ();
00445               case 'h':                 /* help */
00446                      print_help ();
00447                      exit (STATE_OK);
00448               case 'V':                 /* version */
00449                      print_revision (progname, NP_VERSION);
00450                      exit (STATE_OK);
00451               case 'v':                 /* verbose mode */
00452                      flags |= FLAG_VERBOSE;
00453                      break;
00454               case '4':
00455                      address_family = AF_INET;
00456                      break;
00457               case '6':
00458 #ifdef USE_IPV6
00459                      address_family = AF_INET6;
00460 #else
00461                      usage4 (_("IPv6 support not available"));
00462 #endif
00463                      break;
00464               case 'H':                 /* hostname */
00465                      server_address = optarg;
00466                      break;
00467               case 'c':                 /* critical */
00468                      critical_time = strtod (optarg, NULL);
00469                      flags |= FLAG_TIME_CRIT;
00470                      break;
00471               case 'j':              /* hide output */
00472                      flags |= FLAG_HIDE_OUTPUT;
00473                      break;
00474               case 'w':                 /* warning */
00475                      warning_time = strtod (optarg, NULL);
00476                      flags |= FLAG_TIME_WARN;
00477                      break;
00478               case 'C':
00479                      crit_codes = realloc (crit_codes, ++crit_codes_count);
00480                      crit_codes[crit_codes_count - 1] = optarg;
00481                      break;
00482               case 'W':
00483                      warn_codes = realloc (warn_codes, ++warn_codes_count);
00484                      warn_codes[warn_codes_count - 1] = optarg;
00485                      break;
00486               case 't':                 /* timeout */
00487                      if (!is_intpos (optarg))
00488                             usage4 (_("Timeout interval must be a positive integer"));
00489                      else
00490                             socket_timeout = atoi (optarg);
00491                      break;
00492               case 'p':                 /* port */
00493                      if (!is_intpos (optarg))
00494                             usage4 (_("Port must be a positive integer"));
00495                      else
00496                             server_port = atoi (optarg);
00497                      break;
00498               case 'E':
00499                      escape = 1;
00500                      break;
00501               case 's':
00502                      if (escape)
00503                             server_send = np_escaped_string(optarg);
00504                      else
00505                             asprintf(&server_send, "%s", optarg);
00506                      break;
00507               case 'e': /* expect string (may be repeated) */
00508                      flags &= ~FLAG_EXACT_MATCH;
00509                      if (server_expect_count == 0)
00510                             server_expect = malloc (sizeof (char *) * (++server_expect_count));
00511                      else
00512                             server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count));
00513                      server_expect[server_expect_count - 1] = optarg;
00514                      break;
00515               case 'm':
00516                      if (!is_intpos (optarg))
00517                             usage4 (_("Maxbytes must be a positive integer"));
00518                      else
00519                             maxbytes = strtol (optarg, NULL, 0);
00520                      break;
00521               case 'q':
00522                      if (escape)
00523                             server_quit = np_escaped_string(optarg);
00524                      else
00525                             asprintf(&server_quit, "%s\r\n", optarg);
00526                      break;
00527               case 'r':
00528                      if (!strncmp(optarg,"ok",2))
00529                             econn_refuse_state = STATE_OK;
00530                      else if (!strncmp(optarg,"warn",4))
00531                             econn_refuse_state = STATE_WARNING;
00532                      else if (!strncmp(optarg,"crit",4))
00533                             econn_refuse_state = STATE_CRITICAL;
00534                      else
00535                             usage4 (_("Refuse must be one of ok, warn, crit"));
00536                      break;
00537               case 'M':
00538                      if (!strncmp(optarg,"ok",2))
00539                             expect_mismatch_state = STATE_OK;
00540                      else if (!strncmp(optarg,"warn",4))
00541                             expect_mismatch_state = STATE_WARNING;
00542                      else if (!strncmp(optarg,"crit",4))
00543                             expect_mismatch_state = STATE_CRITICAL;
00544                      else
00545                             usage4 (_("Mismatch must be one of ok, warn, crit"));
00546                      break;
00547               case 'd':
00548                      if (is_intpos (optarg))
00549                             delay = atoi (optarg);
00550                      else
00551                             usage4 (_("Delay must be a positive integer"));
00552                      break;
00553               case 'D': /* Check SSL cert validity - days 'til certificate expiration */
00554 #ifdef HAVE_SSL
00555 #  ifdef USE_OPENSSL /* XXX */
00556                      if ((temp=strchr(optarg,','))!=NULL) {
00557                          *temp='\0';
00558                          if (!is_intnonneg (temp))
00559                                usage2 (_("Invalid certificate expiration period"), optarg);                             days_till_exp_warn = atoi(optarg);
00560                          *temp=',';
00561                          temp++;
00562                          if (!is_intnonneg (temp))
00563                             usage2 (_("Invalid certificate expiration period"), temp);
00564                          days_till_exp_crit = atoi (temp);
00565                      }
00566                      else {
00567                          days_till_exp_crit=0;
00568                          if (!is_intnonneg (optarg))
00569                             usage2 (_("Invalid certificate expiration period"), optarg);
00570                          days_till_exp_warn = atoi (optarg);
00571                      }
00572                      check_cert = TRUE;
00573                      flags |= FLAG_SSL;
00574                      break;
00575 #  endif /* USE_OPENSSL */
00576 #endif
00577                      /* fallthrough if we don't have ssl */
00578               case 'S':
00579 #ifdef HAVE_SSL
00580                      flags |= FLAG_SSL;
00581 #else
00582                      die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
00583 #endif
00584                      break;
00585               case 'A':
00586                      flags |= FLAG_MATCH_ALL;
00587                      break;
00588               }
00589        }
00590 
00591        if (server_address == NULL)
00592               usage4 (_("You must provide a server address"));
00593        else if (server_address[0] != '/' && is_host (server_address) == FALSE)
00594               die (STATE_CRITICAL, "%s %s - %s: %s\n", SERVICE, state_text(STATE_CRITICAL), _("Invalid hostname, address or socket"), server_address);
00595 
00596        return TRUE;
00597 }
00598 
00599 
00600 void
00601 print_help (void)
00602 {
00603        print_revision (progname, NP_VERSION);
00604 
00605        printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
00606        printf (COPYRIGHT, copyright, email);
00607 
00608        printf (_("This plugin tests %s connections with the specified host (or unix socket).\n\n"),
00609                SERVICE);
00610 
00611        print_usage ();
00612 
00613        printf (UT_HELP_VRSN);
00614        printf (UT_EXTRA_OPTS);
00615 
00616        printf (UT_HOST_PORT, 'p', "none");
00617 
00618        printf (UT_IPv46);
00619 
00620        printf (" %s\n", "-E, --escape");
00621   printf ("    %s\n", _("Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or quit option"));
00622   printf ("    %s\n", _("Default: nothing added to send, \\r\\n added to end of quit"));
00623   printf (" %s\n", "-s, --send=STRING");
00624   printf ("    %s\n", _("String to send to the server"));
00625   printf (" %s\n", "-e, --expect=STRING");
00626   printf ("    %s %s\n", _("String to expect in server response"), _("(may be repeated)"));
00627   printf (" %s\n", "-A, --all");
00628   printf ("    %s\n", _("All expect strings need to occur in server response. Default is any"));
00629   printf (" %s\n", "-q, --quit=STRING");
00630   printf ("    %s\n", _("String to send server to initiate a clean close of the connection"));
00631   printf (" %s\n", "-r, --refuse=ok|warn|crit");
00632   printf ("    %s\n", _("Accept TCP refusals with states ok, warn, crit (default: crit)"));
00633   printf (" %s\n", "-M, --mismatch=ok|warn|crit");
00634   printf ("    %s\n", _("Accept expected string mismatches with states ok, warn, crit (default: warn)"));
00635   printf (" %s\n", "-j, --jail");
00636   printf ("    %s\n", _("Hide output from TCP socket"));
00637   printf (" %s\n", "-m, --maxbytes=INTEGER");
00638   printf ("    %s\n", _("Close connection once more than this number of bytes are received"));
00639   printf (" %s\n", "-d, --delay=INTEGER");
00640   printf ("    %s\n", _("Seconds to wait between sending string and polling for response"));
00641 
00642 #ifdef HAVE_SSL
00643        printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]");
00644   printf ("    %s\n", _("Minimum number of days a certificate has to be valid."));
00645   printf ("    %s\n", _("1st is #days for warning, 2nd is critical (if not specified - 0)."));
00646   printf (" %s\n", "-S, --ssl");
00647   printf ("    %s\n", _("Use SSL for the connection."));
00648 #endif
00649 
00650        printf (UT_WARN_CRIT);
00651 
00652        printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
00653 
00654        printf (UT_VERBOSE);
00655 
00656        printf (UT_SUPPORT);
00657 }
00658 
00659 
00660 void
00661 print_usage (void)
00662 {
00663        printf ("%s\n", _("Usage:"));
00664   printf ("%s -H host -p port [-w <warning time>] [-c <critical time>] [-s <send string>]\n",progname);
00665   printf ("[-e <expect string>] [-q <quit string>][-m <maximum bytes>] [-d <delay>]\n");
00666   printf ("[-t <timeout seconds>] [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]\n");
00667   printf ("[-D <warn days cert expire>[,<crit days cert expire>]] [-S <use SSL>] [-E]\n");
00668 }
00669