diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_tcp.c | 142 |
1 files changed, 68 insertions, 74 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 158475e..4da2ea5 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -1,32 +1,58 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * This file is part of the Nagios Plugins. | 3 | * This program is free software; you can redistribute it and/or modify |
4 | * | 4 | * it under the terms of the GNU General Public License as published by |
5 | * Copyright (c) 1999 Ethan Galstad <nagios@nagios.org> | 5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * | 6 | * (at your option) any later version. |
7 | * The Nagios Plugins are free software; you can redistribute them | 7 | * |
8 | * and/or modify them under the terms of the GNU General Public | 8 | * This program is distributed in the hope that it will be useful, |
9 | * License as published by the Free Software Foundation; either | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * | 11 | * GNU General Public License for more details. |
12 | * This program is distributed in the hope that it will be useful, but | 12 | * |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * You should have received a copy of the GNU General Public License |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | * along with this program; if not, write to the Free Software |
15 | * General Public License for more details. | 15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * | 16 | * |
17 | * You should have received a copy of the GNU General Public License | 17 | *****************************************************************************/ |
18 | * along with this program; if not, write to the Free Software | 18 | |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | const char *progname = "check_tcp"; |
20 | * | 20 | const char *revision = "$Revision$"; |
21 | * $Id$ | 21 | const char *copyright = "2002-2003"; |
22 | * | 22 | const char *authors = "Nagios Plugin Development Team"; |
23 | *****************************************************************************/ | 23 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
24 | 24 | ||
25 | #define REVISION "$Revision$" | 25 | const char *summary = "\ |
26 | #define DESCRIPTION "Check a TCP port" | 26 | This plugin tests %s connections with the specified host.\n"; |
27 | #define AUTHOR "Ethan Galstad" | 27 | |
28 | #define EMAIL "nagios@nagios.org" | 28 | const char *option_summary = "\ |
29 | #define COPYRIGHTDATE "2002" | 29 | -H host -p port [-w warn_time] [-c crit_time] [-s send]\n\ |
30 | [-e expect] [-W wait] [-t to_sec] [-v]\n"; | ||
31 | |||
32 | const char *options = "\ | ||
33 | -H, --hostname=ADDRESS\n\ | ||
34 | Host name argument for servers using host headers (use numeric\n\ | ||
35 | address if possible to bypass DNS lookup).\n\ | ||
36 | -p, --port=INTEGER\n\ | ||
37 | Port number\n\ | ||
38 | -s, --send=STRING\n\ | ||
39 | String to send to the server\n\ | ||
40 | -e, --expect=STRING\n\ | ||
41 | String to expect in server response\n\ | ||
42 | -W, --wait=INTEGER\n\ | ||
43 | Seconds to wait between sending string and polling for response\n\ | ||
44 | -w, --warning=DOUBLE\n\ | ||
45 | Response time to result in warning status (seconds)\n\ | ||
46 | -c, --critical=DOUBLE\n\ | ||
47 | Response time to result in critical status (seconds)\n\ | ||
48 | -t, --timeout=INTEGER\n\ | ||
49 | Seconds before connection times out (default: %d)\n\ | ||
50 | -v\n\ | ||
51 | Show details for command-line debugging (do not use with nagios server)\n\ | ||
52 | -h, --help\n\ | ||
53 | Print detailed help screen\n\ | ||
54 | -V, --version\n\ | ||
55 | Print version information"; | ||
30 | 56 | ||
31 | #include "config.h" | 57 | #include "config.h" |
32 | #include "common.h" | 58 | #include "common.h" |
@@ -68,7 +94,6 @@ void print_usage (void); | |||
68 | void print_help (void); | 94 | void print_help (void); |
69 | int my_recv (void); | 95 | int my_recv (void); |
70 | 96 | ||
71 | char *progname = "check_tcp"; | ||
72 | char *SERVICE = NULL; | 97 | char *SERVICE = NULL; |
73 | char *SEND = NULL; | 98 | char *SEND = NULL; |
74 | char *EXPECT = NULL; | 99 | char *EXPECT = NULL; |
@@ -467,59 +492,28 @@ process_arguments (int argc, char **argv) | |||
467 | return OK; | 492 | return OK; |
468 | } | 493 | } |
469 | 494 | ||
470 | |||
471 | |||
472 | |||
473 | |||
474 | void | 495 | void |
475 | print_usage (void) | 496 | print_help (void) |
476 | { | 497 | { |
477 | printf | 498 | print_revision (progname, revision); |
478 | ("Usage: %s -H host -p port [-w warn_time] [-c crit_time] [-s send]\n" | 499 | printf ("Copyright (c) %s %s\n\t<%s>\n\n", |
479 | " [-e expect] [-W wait] [-t to_sec] [-v]\n", progname); | 500 | copyright, authors, email); |
501 | printf (summary, SERVICE); | ||
502 | print_usage (); | ||
503 | printf ("\nOptions:\n"); | ||
504 | printf (options, DEFAULT_SOCKET_TIMEOUT); | ||
505 | support (); | ||
480 | } | 506 | } |
481 | 507 | ||
482 | |||
483 | |||
484 | |||
485 | |||
486 | void | 508 | void |
487 | print_help (void) | 509 | print_usage (void) |
488 | { | 510 | { |
489 | print_revision (progname, "$Revision$"); | 511 | printf |
490 | printf | 512 | ("Usage: %s %s\n" |
491 | ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n" | 513 | " %s (-h|--help)\n" |
492 | "This plugin tests %s connections with the specified host.\n\n", | 514 | " %s (-V|--version)\n", progname, option_summary, progname, progname); |
493 | SERVICE); | ||
494 | print_usage (); | ||
495 | printf | ||
496 | ("Options:\n" | ||
497 | " -H, --hostname=ADDRESS\n" | ||
498 | " Host name argument for servers using host headers (use numeric\n" | ||
499 | " address if possible to bypass DNS lookup).\n" | ||
500 | " -p, --port=INTEGER\n" | ||
501 | " Port number\n" | ||
502 | " -s, --send=STRING\n" | ||
503 | " String to send to the server\n" | ||
504 | " -e, --expect=STRING\n" | ||
505 | " String to expect in server response" | ||
506 | " -W, --wait=INTEGER\n" | ||
507 | " Seconds to wait between sending string and polling for response\n" | ||
508 | " -w, --warning=DOUBLE\n" | ||
509 | " Response time to result in warning status (seconds)\n" | ||
510 | " -c, --critical=DOUBLE\n" | ||
511 | " Response time to result in critical status (seconds)\n" | ||
512 | " -t, --timeout=INTEGER\n" | ||
513 | " Seconds before connection times out (default: %d)\n" | ||
514 | " -v" | ||
515 | " Show details for command-line debugging (do not use with nagios server)\n" | ||
516 | " -h, --help\n" | ||
517 | " Print detailed help screen\n" | ||
518 | " -V, --version\n" | ||
519 | " Print version information\n", DEFAULT_SOCKET_TIMEOUT); | ||
520 | } | 515 | } |
521 | 516 | ||
522 | |||
523 | #ifdef HAVE_SSL | 517 | #ifdef HAVE_SSL |
524 | int | 518 | int |
525 | connect_SSL (void) | 519 | connect_SSL (void) |