summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am8
-rw-r--r--plugins/check_tcp.c123
-rw-r--r--plugins/common.h15
-rw-r--r--plugins/utils.c4
4 files changed, 85 insertions, 65 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 6d817b1..19c02cd 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -2,7 +2,13 @@
2 2
3VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t 3VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t
4 4
5INCLUDES = -I.. -I$(top_srcdir)/lib @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@ 5INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/intl \
6@LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@
7
8datadir = @datadir@
9localedir = $(datadir)/locale
10DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
11LIBS = @LIBINTL@ @LIBS@
6 12
7libexec_PROGRAMS = check_disk check_dummy check_http check_load \ 13libexec_PROGRAMS = check_disk check_dummy check_http check_load \
8 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \ 14 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index ce4fd31..afb1a68 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -15,59 +15,6 @@
15* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16* 16*
17*****************************************************************************/ 17*****************************************************************************/
18
19/* progname changes depending on symlink called */
20char *progname = "check_tcp";
21const char *revision = "$Revision$";
22const char *copyright = "2002-2003";
23const char *authors = "Nagios Plugin Development Team";
24const char *email = "nagiosplug-devel@lists.sourceforge.net";
25
26const char *summary = "\
27This plugin tests %s connections with the specified host.\n";
28
29const char *option_summary = "\
30-H host -p port [-w warn_time] [-c crit_time] [-s send_string]\n\
31 [-e expect_string] [-q quit_string] [-m maxbytes] [-d delay]\n\
32 [-t to_sec] [-r refuse_state] [-v] [-4|-6]\n";
33
34const char *options = "\
35 -H, --hostname=ADDRESS\n\
36 Host name argument for servers using host headers (use numeric\n\
37 address if possible to bypass DNS lookup).\n\
38 -p, --port=INTEGER\n\
39 Port number\n\
40 -4, --use-ipv4\n\
41 Use IPv4 connection\n\
42 -6, --use-ipv6\n\
43 Use IPv6 connection\n\
44 -s, --send=STRING\n\
45 String to send to the server\n\
46 -e, --expect=STRING\n\
47 String to expect in server response\n\
48 -q, --quit=STRING\n\
49 String to send server to initiate a clean close of the connection\n\
50 -m, --maxbytes=INTEGER\n\
51 Close connection once more than this number of bytes are received\n\
52 -d, --delay=INTEGER\n\
53 Seconds to wait between sending string and polling for response\n\
54 -w, --warning=DOUBLE\n\
55 Response time to result in warning status (seconds)\n\
56 -c, --critical=DOUBLE\n\
57 Response time to result in critical status (seconds)\n\
58 -t, --timeout=INTEGER\n\
59 Seconds before connection times out (default: %d)\n\
60 -r, --refuse=ok|warn|crit\n\
61 Accept tcp refusals with states ok, warn, crit (default: crit)\n\
62 -v, --verbose\n\
63 Show details for command-line debugging (Nagios may truncate output)\n";
64
65const char *standard_options = "\
66 -h, --help\n\
67 Print detailed help screen\n\
68 -V, --version\n\
69 Print version information\n\n";
70
71#include "config.h" 18#include "config.h"
72#include "common.h" 19#include "common.h"
73#include "netutils.h" 20#include "netutils.h"
@@ -137,6 +84,13 @@ int use_ssl = FALSE;
137int sd = 0; 84int sd = 0;
138char *buffer = ""; 85char *buffer = "";
139 86
87/* progname changes depending on symlink called */
88char *progname = "check_tcp";
89const char *revision = "$Revision$";
90const char *copyright = "2002-2003";
91const char *authors = "Nagios Plugin Development Team";
92const char *email = "nagiosplug-devel@lists.sourceforge.net";
93
140int 94int
141main (int argc, char **argv) 95main (int argc, char **argv)
142{ 96{
@@ -145,6 +99,10 @@ main (int argc, char **argv)
145 char *status = ""; 99 char *status = "";
146 struct timeval tv; 100 struct timeval tv;
147 101
102 setlocale (LC_ALL, "");
103 bindtextdomain (PACKAGE, LOCALEDIR);
104 textdomain (PACKAGE);
105
148 if (strstr (argv[0], "check_udp")) { 106 if (strstr (argv[0], "check_udp")) {
149 progname = strdup ("check_udp"); 107 progname = strdup ("check_udp");
150 SERVICE = strdup ("UDP"); 108 SERVICE = strdup ("UDP");
@@ -301,7 +259,7 @@ main (int argc, char **argv)
301 asprintf (&status, "%s%s", status, buffer); 259 asprintf (&status, "%s%s", status, buffer);
302 if (buffer[i-2] == '\r' && buffer[i-1] == '\n') 260 if (buffer[i-2] == '\r' && buffer[i-1] == '\n')
303 break; 261 break;
304 if (maxbytes>0 && strlen(status)>=maxbytes) 262 if (maxbytes>0 && strlen(status) >= (unsigned)maxbytes)
305 break; 263 break;
306 } 264 }
307 265
@@ -547,19 +505,68 @@ void
547print_help (void) 505print_help (void)
548{ 506{
549 print_revision (progname, revision); 507 print_revision (progname, revision);
508
550 printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email); 509 printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email);
551 printf (summary, SERVICE); 510
511 printf (_("\
512This plugin tests %s connections with the specified host.\n"), SERVICE);
513
552 print_usage (); 514 print_usage ();
515
553 printf ("\nOptions:\n"); 516 printf ("\nOptions:\n");
554 printf (options, DEFAULT_SOCKET_TIMEOUT); 517
555 printf (standard_options); 518 printf (_("\
519 -H, --hostname=ADDRESS\n\
520 Host name argument for servers using host headers (use numeric\n\
521 address if possible to bypass DNS lookup).\n\
522 -p, --port=INTEGER\n\
523 Port number\n\
524 -4, --use-ipv4\n\
525 Use IPv4 connection\n\
526 -6, --use-ipv6\n\
527 Use IPv6 connection\n"));
528
529 printf (_("\
530 -s, --send=STRING\n\
531 String to send to the server\n\
532 -e, --expect=STRING\n\
533 String to expect in server response\n\
534 -q, --quit=STRING\n\
535 String to send server to initiate a clean close of the connection\n"));
536
537 printf (_("\
538 -r, --refuse=ok|warn|crit\n\
539 Accept tcp refusals with states ok, warn, crit (default: crit)\n\
540 -m, --maxbytes=INTEGER\n\
541 Close connection once more than this number of bytes are received\n\
542 -d, --delay=INTEGER\n\
543 Seconds to wait between sending string and polling for response\n\
544 -w, --warning=DOUBLE\n\
545 Response time to result in warning status (seconds)\n\
546 -c, --critical=DOUBLE\n\
547 Response time to result in critical status (seconds)\n"));
548
549 printf (_("\
550 -t, --timeout=INTEGER\n\
551 Seconds before connection times out (default: %d)\n\
552 -v, --verbose\n\
553 Show details for command-line debugging (Nagios may truncate output)\n\
554 -h, --help\n\
555 Print detailed help screen\n\
556 -V, --version\n\
557 Print version information\n\n"),
558 DEFAULT_SOCKET_TIMEOUT);
559
556 support (); 560 support ();
557} 561}
558 562
559void 563void
560print_usage (void) 564print_usage (void)
561{ 565{
562 printf ("Usage: %s %s\n", progname, option_summary); 566 printf ("Usage: %s %s\n", progname, _("\
567-H host -p port [-w warn_time] [-c crit_time] [-s send_string]\n\
568 [-e expect_string] [-q quit_string] [-m maxbytes] [-d delay]\n\
569 [-t to_sec] [-r refuse_state] [-v] [-4|-6]\n"));
563 printf (" %s (-h|--help)\n", progname); 570 printf (" %s (-h|--help)\n", progname);
564 printf (" %s (-V|--version)\n", progname); 571 printf (" %s (-V|--version)\n", progname);
565} 572}
diff --git a/plugins/common.h b/plugins/common.h
index 21facfc..2456c41 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -156,7 +156,14 @@ enum {
156 * 156 *
157 */ 157 */
158 158
159#define _(String) (String) 159#if ENABLE_NLS
160#define N_(String) String 160# include "gettext.h"
161#define textdomain(Domain) 161# define _(String) gettext (String)
162#define bindtextdomain(Package, Directory) 162# define gettext_noop(String) String
163# define N_(String) gettext_noop String
164#else
165# define _(String) (String)
166# define N_(String) String
167# define textdomain(Domain)
168# define bindtextdomain(Package, Directory)
169#endif
diff --git a/plugins/utils.c b/plugins/utils.c
index d0999c5..e63c8c0 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -133,8 +133,8 @@ print_revision (const char *command_name, const char *revision_string)
133 133
134 if (sscanf (revision_string, "$Revision: %[0-9.]", plugin_revision) != 1) 134 if (sscanf (revision_string, "$Revision: %[0-9.]", plugin_revision) != 1)
135 strncpy (plugin_revision, "N/A", STRLEN); 135 strncpy (plugin_revision, "N/A", STRLEN);
136 printf ("%s (nagios-plugins %s) %s\n", 136 printf ("%s (%s %s) %s\n",
137 progname, VERSION, plugin_revision); 137 progname, PACKAGE, VERSION, plugin_revision);
138 printf 138 printf
139 ("The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n" 139 ("The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"
140 "copies of the plugins under the terms of the GNU General Public License.\n" 140 "copies of the plugins under the terms of the GNU General Public License.\n"