From b07cec408f61acd3c34ad1c03b212bba9b66c454 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Sat, 2 Aug 2003 16:42:57 +0000 Subject: [PATCH] establish "UT_" namespace for usage text in #defines git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@631 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/check_by_ssh.c | 10 ++++++---- plugins/check_dig.c | 10 ++++++---- plugins/check_disk.c | 8 +++++--- plugins/check_dns.c | 37 +++++++++++++++++-------------------- plugins/check_dummy.c | 4 +++- plugins/check_pgsql.c | 12 +++++++----- plugins/check_swap.c | 2 +- plugins/check_tcp.c | 18 ++++++++++-------- plugins/utils.h | 16 +++++++--------- 9 files changed, 62 insertions(+), 55 deletions(-) diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index de106f2..ae19253 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -49,11 +49,11 @@ print_help (void) print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); - printf (_(HOST_PORT), 'p', "none"); + printf (_(UT_HOST_PORT), 'p', "none"); - printf (_(IPv46)); + printf (_(UT_IPv46)); printf (_("\ -1, --proto1\n\ @@ -77,7 +77,9 @@ print_help (void) -n, --name=NAME\n\ short name of host in nagios configuration [optional]\n")); - printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT); + printf (_(UT_WARN_CRIT)); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); printf (_("\n\ The most common mode of use is to refer to a local identity file with\n\ diff --git a/plugins/check_dig.c b/plugins/check_dig.c index a22a68a..3d82298 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c @@ -62,17 +62,19 @@ print_help (void) print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); - printf (_(HOST_PORT), 'P', myport); + printf (_(UT_HOST_PORT), 'P', myport); printf (_("\ -l, --lookup=STRING\n\ machine name to lookup\n")); - printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT); + printf (_(UT_WARN_CRIT)); - printf (_(VRBS)); + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); support (); } diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 9de3fad..c758530 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -59,7 +59,7 @@ and generates an alert if free space is less than one of the threshold values.") print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); printf (_("\ -w, --warning=INTEGER\n\ @@ -95,9 +95,11 @@ and generates an alert if free space is less than one of the threshold values.") -e, --errors-only\n\ Display only devices/mountpoints with errors\n")); - printf (_(TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + printf (_(UT_WARN_CRIT)); - printf (_(VRBS)); + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); printf ("%s", _("Examples:\n\ check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n\ diff --git a/plugins/check_dns.c b/plugins/check_dns.c index d96e9bb..eae5880 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -73,7 +73,7 @@ print_help (void) print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); printf (_("\ -H, --hostname=HOST\n\ @@ -83,7 +83,7 @@ print_help (void) -a, --expected-address=IP-ADDRESS\n\ Optional IP address you expect the DNS server to return\n")); - printf (_(TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); printf (_("\n\ This plugin uses the nslookup program to obtain the IP address\n\ @@ -155,9 +155,9 @@ main (int argc, char **argv) if (strstr (input_buffer, ".in-addr.arpa")) { if ((temp_buffer = strstr (input_buffer, "name = "))) - address = strscpy (address, temp_buffer + 7); + address = strdup (temp_buffer + 7); else { - output = strscpy (output, _("Unknown error (plugin)")); + output = strdup (_("Unknown error (plugin)")); result = STATE_WARNING; } } @@ -195,7 +195,7 @@ main (int argc, char **argv) result = error_scan (input_buffer); if (result != STATE_OK) { - output = strscpy (output, 1 + index (input_buffer, ':')); + output = strdup (1 + index (input_buffer, ':')); strip (output); break; } @@ -206,7 +206,7 @@ main (int argc, char **argv) while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { if (error_scan (input_buffer) != STATE_OK) { result = max_state (result, error_scan (input_buffer)); - output = strscpy (output, 1 + index (input_buffer, ':')); + output = strdup (1 + index (input_buffer, ':')); strip (output); } } @@ -218,7 +218,7 @@ main (int argc, char **argv) if (spclose (child_process)) { result = max_state (result, STATE_WARNING); if (!strcmp (output, "")) - output = strscpy (output, _("nslookup returned error status")); + output = strdup (_("nslookup returned error status")); } /* If we got here, we should have an address string, @@ -268,42 +268,39 @@ error_scan (char *input_buffer) strstr (input_buffer, "the `-sil[ent]' option to prevent this message from appearing.")) return STATE_OK; - /* the DNS lookup timed out */ - else if (strstr (input_buffer, "Timed out")) - terminate (STATE_WARNING, "Request timed out at server\n"); - /* DNS server is not running... */ else if (strstr (input_buffer, "No response from server")) - terminate (STATE_CRITICAL, "No response from name server %s\n", dns_server); + terminate (STATE_CRITICAL, _("No response from name server %s\n"), dns_server); /* Host name is valid, but server doesn't have records... */ else if (strstr (input_buffer, "No records")) - terminate (STATE_CRITICAL, "Name server %s has no records\n", dns_server); + terminate (STATE_CRITICAL, _("Name server %s has no records\n"), dns_server); /* Connection was refused */ else if (strstr (input_buffer, "Connection refused") || (strstr (input_buffer, "** server can't find") && strstr (input_buffer, ": REFUSED")) || (strstr (input_buffer, "Refused"))) - terminate (STATE_CRITICAL, "Connection to name server %s was refused\n", dns_server); + terminate (STATE_CRITICAL, _("Connection to name server %s was refused\n"), dns_server); /* Host or domain name does not exist */ else if (strstr (input_buffer, "Non-existent") || strstr (input_buffer, "** server can't find") || strstr (input_buffer,"NXDOMAIN")) - terminate (STATE_CRITICAL, "Domain %s was not found by the server\n", query_address); + terminate (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address); /* Network is unreachable */ else if (strstr (input_buffer, "Network is unreachable")) - terminate (STATE_CRITICAL, "Network is unreachable\n"); + terminate (STATE_CRITICAL, _("Network is unreachable\n")); /* Internal server failure */ else if (strstr (input_buffer, "Server failure")) - terminate (STATE_CRITICAL, "Server failure for %s\n", dns_server); + terminate (STATE_CRITICAL, _("Server failure for %s\n"), dns_server); - /* Request error */ - else if (strstr (input_buffer, "Format error")) - terminate (STATE_WARNING, "Format error\n"); + /* Request error or the DNS lookup timed out */ + else if (strstr (input_buffer, "Format error") || + strstr (input_buffer, "Timed out")) + return STATE_WARNING; return STATE_OK; diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c index c2f1f50..d90b140 100644 --- a/plugins/check_dummy.c +++ b/plugins/check_dummy.c @@ -57,11 +57,13 @@ print_help (void) print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); printf (_("\n\ This plugin will simply return the state corresponding to the numeric value\n\ of the argument.\n")); + + support (); } int diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 2d2f6d3..2dce0b3 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c @@ -136,11 +136,11 @@ print_help (void) print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); - printf (_(HOST_PORT), 'P', myport); + printf (_(UT_HOST_PORT), 'P', myport); - printf (_(IPv46)); + printf (_(UT_IPv46)); printf (S_("\ -d, --database=STRING\n\ @@ -150,9 +150,11 @@ print_help (void) -p, --password = STRING\n\ Password (BIG SECURITY ISSUE)\n"), DEFAULT_DB); - printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT); + printf (_(UT_WARN_CRIT)); - printf (_(VRBS)); + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); printf (S_("\nAll parameters are optional.\n\ \n\ diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 6dd2e08..65cd899 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -77,7 +77,7 @@ print_help (void) print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); printf (_("\n\ -w, --warning=INTEGER\n\ diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 39f9022..12fa404 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -98,9 +98,9 @@ print_usage (void) { printf (_("\ Usage: %s -H host -p port [-w ] [-c ]\n\ - [-s ] [-e ] [-q ]\n\ - [-m ] [-d ] [-t ]\n\ - [-r ] [-v] [-4|-6]\n"), progname); + [-s ] [-e ] [-q ]\n\ + [-m ] [-d ] [-t ]\n\ + [-r ] [-v] [-4|-6]\n"), progname); printf (" %s (-h|--help)\n", progname); printf (" %s (-V|--version)\n", progname); } @@ -116,11 +116,11 @@ print_help (void) print_usage (); - printf (_(HELP_VRSN)); + printf (_(UT_HELP_VRSN)); - printf (_(HOST_PORT), 'p', "none"); + printf (_(UT_HOST_PORT), 'p', "none"); - printf (_(IPv46)); + printf (_(UT_IPv46)); printf (_("\ -s, --send=STRING\n\ @@ -138,9 +138,11 @@ print_help (void) -d, --delay=INTEGER\n\ Seconds to wait between sending string and polling for response\n")); - printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT); + printf (_(UT_WARN_CRIT)); - printf (_(VRBS)); + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); support (); } diff --git a/plugins/utils.h b/plugins/utils.h index d95422a..b10f0e5 100644 --- a/plugins/utils.h +++ b/plugins/utils.h @@ -92,37 +92,35 @@ char *state_text (int result); #define COPYRIGHT "Copyright (c) %s Nagios Plugin Development Team\n\ \t<%s>\n\n" -#define HELP_VRSN "\ +#define UT_HELP_VRSN "\ \nOptions:\n\ -h, --help\n\ Print detailed help screen\n\ -V, --version\n\ Print version information\n" -#define HOST_PORT "\ +#define UT_HOST_PORT "\ -H, --hostname=ADDRESS\n\ Host name or IP Address\n\ -%c, --port=INTEGER\n\ Port number (default: %s)\n" -#define IPv46 "\ +#define UT_IPv46 "\ -4, --use-ipv4\n\ Use IPv4 connection\n\ -6, --use-ipv6\n\ Use IPv6 connection\n" -#define VRBS "\ +#define UT_VERBOSE "\ -v, --verbose\n\ Show details for command-line debugging (Nagios may truncate output)\n" -#define WARN_CRIT_TO "\ +#define UT_WARN_CRIT "\ -w, --warning=DOUBLE\n\ Response time to result in warning status (seconds)\n\ -c, --critical=DOUBLE\n\ - Response time to result in critical status (seconds)\n\ - -t, --timeout=INTEGER\n\ - Seconds before connection times out (default: %d)\n" + Response time to result in critical status (seconds)\n" -#define TIMEOUT "\ +#define UT_TIMEOUT "\ -t, --timeout=INTEGER\n\ Seconds before connection times out (default: %d)\n" -- 2.30.2