summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1cb0499)
raw | patch | inline | side by side (parent: 1cb0499)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 30 Jul 2003 04:07:53 +0000 (04:07 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 30 Jul 2003 04:07:53 +0000 (04:07 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@620 f882894a-f735-0410-b71e-b25c423dba1c
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 6e0408744f2902ea55d28c42f29fdc7895398ef9..a22a68ac196fbedfd7955d2f42f89e4ca1e82752 100644 (file)
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
*
*****************************************************************************/
+#include "config.h"
+#include "common.h"
+#include "netutils.h"
+#include "utils.h"
+#include "popen.h"
+
+int process_arguments (int, char **);
+int validate_arguments (void);
+void print_help (void);
+void print_usage (void);
+
const char *progname = "check_dig";
const char *revision = "$Revision$";
const char *copyright = "2002-2003";
-const char *authors = "Nagios Plugin Development Team";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
-const char *summary = "Test the DNS service on the specified host using dig\n";
+enum {
+ DEFAULT_PORT = 53
+};
+
+void
+print_usage (void)
+{
+ printf (_("\
+Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\
+ [-c <critical interval>] [-t <timeout>] [-v]\n"),
+ progname);
+ printf (" %s (-h|--help)\n", progname);
+ printf (" %s (-V|--version)\n", progname);
+}
+
+void
+print_help (void)
+{
+ char *myport;
+
+ asprintf (&myport, "%d", DEFAULT_PORT);
+
+ print_revision (progname, revision);
-const char *option_summary = "-H host -l lookup [-t timeout] [-v]";
+ printf (_(COPYRIGHT), copyright, email);
-const char *options = "\
- -H, --hostname=STRING or IPADDRESS\n\
- Check server on the indicated host\n\
+ printf (_("Test the DNS service on the specified host using dig\n\n"));
+
+ print_usage ();
+
+ printf (_(HELP_VRSN));
+
+ printf (_(HOST_PORT), 'P', myport);
+
+ printf (_("\
-l, --lookup=STRING\n\
- machine name to lookup\n\
- -t, --timeout=INTEGER\n\
- Seconds before connection attempt times out (default: %d)\n\
- -v, --verbose\n\
- Print extra information (command-line use only)\n";
-
-const char *standard_options = "\
- -h, --help\n\
- Print detailed help screen\n\
- -V, --version\n\
- Print version information\n\n";
+ machine name to lookup\n"));
-#include "config.h"
-#include "common.h"
-#include "utils.h"
-#include "popen.h"
+ printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
-int process_arguments (int, char **);
-int validate_arguments (void);
-void print_help (void);
-void print_usage (void);
+ printf (_(VRBS));
+
+ support ();
+}
+\f
char *query_address = NULL;
char *dns_server = NULL;
int verbose = FALSE;
+int server_port = DEFAULT_PORT;
+int warning_interval = -1;
+int critical_interval = -1;
+
int
main (int argc, char **argv)
/* Set signal handling and alarm */
if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR)
- usage ("Cannot catch SIGALRM\n");
+ usage (_("Cannot catch SIGALRM\n"));
if (process_arguments (argc, argv) != OK)
- usage ("Could not parse arguments\n");
+ usage (_("Could not parse arguments\n"));
/* get the command to run */
- asprintf (&command_line, "%s @%s %s", PATH_TO_DIG, dns_server, query_address);
+ asprintf (&command_line, "%s @%s -p %d %s",
+ PATH_TO_DIG, dns_server, server_port, query_address);
alarm (timeout_interval);
time (&start_time);
/* run the command */
child_process = spopen (command_line);
if (child_process == NULL) {
- printf ("Could not open pipe: %s\n", command_line);
+ printf (_("Could not open pipe: %s\n"), command_line);
return STATE_UNKNOWN;
}
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
if (child_stderr == NULL)
- printf ("Could not open stderr for %s\n", command_line);
+ printf (_("Could not open stderr for %s\n"), command_line);
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
result = STATE_OK;
}
else {
- asprintf (&output, "Server not found in ANSWER SECTION");
+ asprintf (&output, _("Server not found in ANSWER SECTION"));
result = STATE_WARNING;
}
}
if (result != STATE_OK) {
- asprintf (&output, "No ANSWER SECTION found");
+ asprintf (&output, _("No ANSWER SECTION found"));
}
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
if (spclose (child_process)) {
result = max_state (result, STATE_WARNING);
if (strlen (output) == 0)
- asprintf (&output, "dig returned error status");
+ asprintf (&output, _("dig returned error status"));
}
(void) time (&end_time);
if (output == NULL || strlen (output) == 0)
- asprintf (&output, " Probably a non-existent host/domain");
+ asprintf (&output, _(" Probably a non-existent host/domain"));
if (result == STATE_OK)
- printf ("DNS OK - %d seconds response time (%s)\n",
+ printf (_("DNS OK - %d seconds response time (%s)\n"),
(int) (end_time - start_time), output);
else if (result == STATE_WARNING)
- printf ("DNS WARNING - %s\n", output);
+ printf (_("DNS WARNING - %s\n"), output);
else if (result == STATE_CRITICAL)
- printf ("DNS CRITICAL - %s\n", output);
+ printf (_("DNS CRITICAL - %s\n"), output);
else
- printf ("DNS problem - %s\n", output);
+ printf (_("DNS problem - %s\n"), output);
return result;
}
switch (c) {
case '?': /* help */
- usage3 ("Unknown argument", optopt);
+ usage3 (_("Unknown argument"), optopt);
+ case 'h': /* help */
+ print_help ();
+ exit (STATE_OK);
+ case 'V': /* version */
+ print_revision (progname, "$Revision$");
+ exit (STATE_OK);
case 'H': /* hostname */
if (is_host (optarg)) {
dns_server = optarg;
}
else {
- usage ("Invalid host name\n");
+ usage2 (_("Invalid host name"), optarg);
+ }
+ break;
+ case 'p':
+ if (is_intpos (optarg)) {
+ server_port = atoi (optarg);
+ }
+ else {
+ usage2 (_("Server port must be a nonnegative integer\n"), optarg);
}
break;
case 'l': /* username */
query_address = optarg;
break;
- case 'v': /* verbose */
- verbose = TRUE;
+ case 'w': /* timeout */
+ if (is_intnonneg (optarg)) {
+ warning_interval = atoi (optarg);
+ }
+ else {
+ usage2 (_("Warning interval must be a nonnegative integer\n"), optarg);
+ }
+ break;
+ case 'c': /* timeout */
+ if (is_intnonneg (optarg)) {
+ critical_interval = atoi (optarg);
+ }
+ else {
+ usage2 (_("Critical interval must be a nonnegative integer\n"), optarg);
+ }
break;
case 't': /* timeout */
if (is_intnonneg (optarg)) {
timeout_interval = atoi (optarg);
}
else {
- usage ("Time interval must be a nonnegative integer\n");
+ usage2 (_("Time interval must be a nonnegative integer\n"), optarg);
}
break;
- case 'V': /* version */
- print_revision (progname, "$Revision$");
- exit (STATE_OK);
- case 'h': /* help */
- print_help ();
- exit (STATE_OK);
+ case 'v': /* verbose */
+ verbose = TRUE;
+ break;
}
}
dns_server = argv[c];
}
else {
- usage ("Invalid host name");
+ usage2 (_("Invalid host name"), argv[c]);
}
}
else {
return OK;
}
\f
-
-
-
-
-void
-print_help (void)
-{
- print_revision (progname, revision);
- printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email);
- printf (summary);
- print_usage ();
- printf ("\nOptions:\n");
- printf (options, DEFAULT_SOCKET_TIMEOUT);
- printf (standard_options);
- support ();
-}
-
-
-
-
-
-void
-print_usage (void)
-{
- printf ("Usage: %s %s\n", progname, option_summary);
- printf (" %s (-h|--help)\n", progname);
- printf (" %s (-V|--version)\n", progname);
-}
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index b532d6816af94295bff99dbc72fa7f8d03a702d5..2d2f6d31e356f6262c3d409156a808352befc146 100644 (file)
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
enum {
DEFAULT_PORT = 5432,
DEFAULT_WARN = 2,
- DEFAULT_CRIT = 8,
- DEFAULT_TIMEOUT = 30
+ DEFAULT_CRIT = 8
};
#include "config.h"
void
print_help (void)
{
+ char *myport;
+
+ asprintf (&myport, "%d", DEFAULT_PORT);
+
print_revision (progname, revision);
printf (_(COPYRIGHT), copyright, email);
printf (_(HELP_VRSN));
- printf (_(HOST_PORT_46), 'P', "5432");
+ printf (_(HOST_PORT), 'P', myport);
+
+ printf (_(IPv46));
printf (S_("\
-d, --database=STRING\n\
-l, --logname = STRING\n\
Login name of user\n\
-p, --password = STRING\n\
- Password (BIG SECURITY ISSUE)\n\n"), DEFAULT_DB);
+ Password (BIG SECURITY ISSUE)\n"), DEFAULT_DB);
printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 5edb8061f25dcd8e1c8184b72ee2ce96513fbb98..6dd2e086c5a89d86a2f85a9233f5665026586b29 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
char *status = "";
if (process_arguments (argc, argv) != OK)
- usage ("Invalid command arguments supplied\n");
+ usage (_("Invalid command arguments supplied\n"));
#ifdef HAVE_PROC_MEMINFO
fp = fopen (PROC_MEMINFO, "r");
}
if (verbose >= 2)
- printf ("Command: %s\n", swap_command);
+ printf (_("Command: %s\n"), swap_command);
if (verbose >= 3)
- printf ("Format: %s\n", swap_format);
+ printf ("_(Format: %s\n"), swap_format);
child_process = spopen (swap_command);
if (child_process == NULL) {
- printf ("Could not open pipe: %s\n", swap_command);
+ printf (_("Could not open pipe: %s\n"), swap_command);
return STATE_UNKNOWN;
}
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
if (child_stderr == NULL)
- printf ("Could not open stderr for %s\n", swap_command);
+ printf (_("Could not open stderr for %s\n"), swap_command);
sprintf (str, "%s", "");
/* read 1st line */
dsktotal = dsktotal / conv_factor;
dskfree = dskfree / conv_factor;
if (verbose >= 3)
- printf ("total=%d, free=%d\n", dsktotal, dskfree);
+ printf (_("total=%d, free=%d\n"), dsktotal, dskfree);
dskused = dsktotal - dskfree;
#endif
}
percent_used = 100 * ((double) used_swap) / ((double) total_swap);
result = max_state (result, check_swap (percent_used, free_swap));
- asprintf (&status, " %d%% free (%lu MB out of %lu MB)%s",
+ asprintf (&status, _(" %d%% free (%lu MB out of %lu MB)%s"),
(100 - percent_used), free_swap, total_swap, status);
#ifdef HAVE_PROC_MEMINFO
break;
}
else {
- usage ("Warning threshold must be integer or percentage!\n");
+ usage (_("Warning threshold must be integer or percentage!\n"));
}
wc++;
case 'c': /* critical time threshold */
break;
}
else {
- usage ("Critical threshold must be integer or percentage!\n");
+ usage (_("Critical threshold must be integer or percentage!\n"));
}
cc++;
case 'a': /* all swap */
print_help ();
exit (STATE_OK);
case '?': /* help */
- usage ("Invalid argument\n");
+ usage (_("Invalid argument\n"));
}
}
}
else if (warn_percent < crit_percent) {
usage
- ("Warning percentage should be more than critical percentage\n");
+ (_("Warning percentage should be more than critical percentage\n"));
}
else if (warn_size < crit_size) {
usage
- ("Warning free space should be more than critical free space\n");
+ (_("Warning free space should be more than critical free space\n"));
}
return OK;
}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index eb31774d1fa4f01f54b9f6aec5c38014f5449db1..39f90222051f82a734d21fe903d30a8525c239e7 100644 (file)
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
printf (_(HELP_VRSN));
- printf (_(HOST_PORT_46), 'p', "none");
+ printf (_(HOST_PORT), 'p', "none");
+
+ printf (_(IPv46));
printf (_("\
-s, --send=STRING\n\
diff --git a/plugins/utils.h b/plugins/utils.h
index 292c3dff1bb8d1f88f3ac78244511e268d49fb28..8a6ffa14b08f8b80afb4c590a26e808bf8e0461a 100644 (file)
--- a/plugins/utils.h
+++ b/plugins/utils.h
-V, --version\n\
Print version information\n"
-#define HOST_PORT_46 "\
+#define HOST_PORT "\
-H, --hostname=ADDRESS\n\
- Host name or IP Address%s\n\
+ Host name or IP Address\n\
-%c, --port=INTEGER\n\
- Port number (default: %s)\n\
+ Port number (default: %s)\n"
+
+#define IPv46 "\
-4, --use-ipv4\n\
Use IPv4 connection\n\
-6, --use-ipv6\n\
-c, --critical=DOUBLE\n\
Response time to result in critical status (seconds)\n\
-t, --timeout=INTEGER\n\
- Seconds before connection times out (default: %s)\n"
+ Seconds before connection times out (default: %d)\n"