Browse Source

mark for translation

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@619 f882894a-f735-0410-b71e-b25c423dba1c
Karl DeBisschop 22 years ago
parent
commit
1cb0499adc
3 changed files with 115 additions and 154 deletions
  1. 23 39
      plugins/check_pgsql.c
  2. 82 81
      plugins/check_swap.c
  3. 10 34
      plugins/check_tcp.c

+ 23 - 39
plugins/check_pgsql.c

@@ -23,13 +23,6 @@
  *
  *****************************************************************************/
 
-const char *progname = "check_pgsql";
-#define REVISION "$Revision$"
-#define COPYRIGHT "1999-2001"
-#define AUTHOR "Karl DeBisschop"
-#define EMAIL "kdebisschop@users.sourceforge.net"
-#define SUMMARY "Tests to see if a PostgreSQL DBMS is accepting connections.\n"
-
 #define DEFAULT_DB "template1"
 #define DEFAULT_HOST "127.0.0.1"
 
@@ -65,6 +58,11 @@ int tcrit = DEFAULT_CRIT;
 
 PGconn *conn;
 /*PGresult   *res;*/
+
+const char *progname = "check_pgsql";
+const char *revision = "$Revision$";
+const char *copyright = "1999-2003";
+const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
 
 /******************************************************************************
@@ -127,22 +125,18 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
 void
 print_help (void)
 {
-	print_revision (progname, REVISION);
-	printf
-		("Copyright (c) %s %s <%s>\n\n%s\n",
-		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
+	print_revision (progname, revision);
+
+	printf (_(COPYRIGHT), copyright, email);
+
+	printf (_("Test whether a PostgreSQL DBMS is accepting connections.\n\n"));
+
 	print_usage ();
-	printf (_("\
-\nOptions:\n\
- -H, --hostname=ADDRESS\n\
-    Host name argument for servers using host headers (use numeric\n\
-    address if possible to bypass DNS lookup).\n\
- -P, --port=INTEGER\n\
-    Port number (default: %d)\n\
- -4, --use-ipv4\n\
-    Use IPv4 connection\n\
- -6, --use-ipv6\n\
-    Use IPv6 connection\n"), DEFAULT_PORT);
+
+	printf (_(HELP_VRSN));
+
+	printf (_(HOST_PORT_46), 'P', "5432");
+
 	printf (S_("\
   -d, --database=STRING\n\
     Database to check (default: %s)\n\
@@ -150,22 +144,12 @@ print_help (void)
     Login name of user\n\
   -p, --password = STRING\n\
     Password (BIG SECURITY ISSUE)\n\n"), DEFAULT_DB);
-	printf (S_("\nOptions:\n\
-  -c, --critical=INTEGER\n\
-    Exit STATE_CRITICAL if connection time exceeds threshold (default: %d)\n\
-  -w, --warning=INTEGER\n\
-    Exit STATE_WARNING if connection time exceeds threshold (default: %d)\n\
-  -t, --timeout=INTEGER\n\
-    Terminate test if timeout limit is exceeded (default: %d)\n"),
-	        DEFAULT_WARN, DEFAULT_CRIT, DEFAULT_TIMEOUT);
-	printf (_("\
- -v, --verbose\n\
-    Show details for command-line debugging (Nagios may truncate output)\n\
- -h, --help\n\
-    Print detailed help screen\n\
- -V, --version\n\
-    Print version information\n\n"));
-	printf (S_("All parameters are optional.\n\
+
+	printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
+
+	printf (_(VRBS));
+
+	printf (S_("\nAll parameters are optional.\n\
 \n\
 This plugin tests a PostgreSQL DBMS to determine whether it is active and\n\
 accepting queries. In its current operation, it simply connects to the\n\
@@ -290,7 +274,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			exit (STATE_OK);
 		case 'V':     /* version */
-			print_revision (progname, REVISION);
+			print_revision (progname, revision);
 			exit (STATE_OK);
 		case 't':     /* timeout period */
 			if (!is_integer (optarg))

+ 82 - 81
plugins/check_swap.c

@@ -30,12 +30,11 @@
 #include "utils.h"
 
 const char *progname = "check_swap";
-#define REVISION "$Revision$"
-#define COPYRIGHT "2000-2002"
-#define AUTHOR "Karl DeBisschop"
-#define EMAIL "kdebisschop@users.sourceforge.net"
-#define SUMMARY "Check swap space on local server.\n"
+const char *revision = "$Revision$";
+const char *copyright = "2000-2003";
+const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
+int check_swap (int usp, int free_swap);
 int process_arguments (int argc, char **argv);
 int validate_arguments (void);
 void print_usage (void);
@@ -52,16 +51,68 @@ int allswaps;
 int sun = 0;	/* defined by compiler if it is a sun solaris system */
 #endif
 
+void
+print_usage (void)
+{
+	printf (_("Usage:\n\
+ %s [-a] -w <used_percentage>%% -c <used_percentage>%%\n\
+ %s [-a] -w <bytes_free> -c <bytes_free>\n\
+ %s (-h | --help) for detailed help\n\
+ %s (-V | --version) for version information\n"),
+	        progname, progname, progname, progname);
+}
+
+
+
+
+
+void
+print_help (void)
+{
+	print_revision (progname, revision);
+
+	printf (_(COPYRIGHT), copyright, email);
+
+	printf (_("Check swap space on local server.\n\n"));
+
+	print_usage ();
+
+	printf (_(HELP_VRSN));
+
+	printf (_("\n\
+ -w, --warning=INTEGER\n\
+   Exit with WARNING status if less than INTEGER bytes of swap space are free\n\
+ -w, --warning=PERCENT%%\n\
+   Exit with WARNING status if less than PERCENT of swap space has been used\n\
+ -c, --critical=INTEGER\n\
+   Exit with CRITICAL status if less than INTEGER bytes of swap space are free\n\
+ -c, --critical=PERCENT%%\n\
+   Exit with CRITCAL status if less than PERCENT of swap space has been used\n\
+ -a, --allswaps\n\
+    Conduct comparisons for all swap partitions, one by one\n"));
+
+#ifdef sun
+	printf (_("\n\
+On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\
+Will be discrepencies because swap -s counts allocated swap and includes\n\
+real memory\n"));
+#endif
+
+	support ();
+}
+
+
+
 int
 main (int argc, char **argv)
 {
 	int percent_used, percent;
 	long unsigned int total_swap = 0, used_swap = 0, free_swap = 0;
-	long unsigned int total, used, free;
-	int conv_factor;		/* Convert to MBs */
+	long unsigned int dsktotal, dskused, dskfree;
 	int result = STATE_OK;
 	char input_buffer[MAX_INPUT_BUFFER];
 #ifdef HAVE_SWAP
+	int conv_factor;		/* Convert to MBs */
 	char *temp_buffer;
 	char *swap_command;
 	char *swap_format;
@@ -78,11 +129,11 @@ main (int argc, char **argv)
 #ifdef HAVE_PROC_MEMINFO
 	fp = fopen (PROC_MEMINFO, "r");
 	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
-		if (sscanf (input_buffer, " %s %lu %lu %lu", str, &total, &used, &free) == 4 &&
+		if (sscanf (input_buffer, " %s %lu %lu %lu", str, &dsktotal, &dskused, &dskfree) == 4 &&
 		    strstr (str, "Swap")) {
-			total = total / 1048576;
-			used = used / 1048576;
-			free = free / 1048576;
+			dsktotal = dsktotal / 1048576;
+			dskused = dskused / 1048576;
+			dskfree = dskfree / 1048576;
 #endif
 #ifdef HAVE_SWAP
 	if (!allswaps && sun) {
@@ -118,7 +169,7 @@ main (int argc, char **argv)
 		while (temp_buffer) {
 			if (strstr (temp_buffer, "blocks"))
 				sprintf (str, "%s %s", str, "%f");
-			else if (strstr (temp_buffer, "free"))
+			else if (strstr (temp_buffer, "dskfree"))
 				sprintf (str, "%s %s", str, "%f");
 			else
 				sprintf (str, "%s %s", str, "%*s");
@@ -133,23 +184,23 @@ main (int argc, char **argv)
 		total_swap = used_swap + free_swap;
 	} else {
 		while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
-			sscanf (input_buffer, swap_format, &total, &free);
+			sscanf (input_buffer, swap_format, &dsktotal, &dskfree);
 
-			total = total / conv_factor;
-			free = free / conv_factor;
+			dsktotal = dsktotal / conv_factor;
+			dskfree = dskfree / conv_factor;
 			if (verbose >= 3)
-				printf ("total=%d, free=%d\n", total, free);
+				printf ("total=%d, free=%d\n", dsktotal, dskfree);
 
-			used = total - free;
+			dskused = dsktotal - dskfree;
 #endif
-			total_swap += total;
-			used_swap += used;
-			free_swap += free;
+			total_swap += dsktotal;
+			used_swap += dskused;
+			free_swap += dskfree;
 			if (allswaps) {
-				percent = 100 * (((double) used) / ((double) total));
-				result = max_state (result, check_swap (percent, free));
+				percent = 100 * (((double) dskused) / ((double) dsktotal));
+				result = max_state (result, check_swap (percent, dskfree));
 				if (verbose)
-					asprintf (&status, "%s [%lu (%d%%)]", status, free, 100 - percent);
+					asprintf (&status, "%s [%lu (%d%%)]", status, dskfree, 100 - percent);
 			}
 		}
 	}
@@ -175,6 +226,7 @@ main (int argc, char **argv)
 #endif
 
 	terminate (result, "SWAP %s:%s\n", state_text (result), status);
+	return STATE_UNKNOWN;
 }
 
 
@@ -186,11 +238,11 @@ check_swap (int usp, int free_swap)
 	int result = STATE_UNKNOWN;
 	if (usp >= 0 && usp >= (100.0 - crit_percent))
 		result = STATE_CRITICAL;
-	else if (crit_size >= 0 && free_swap <= crit_size)
+	else if (crit_size > 0 && (unsigned)free_swap <= crit_size)
 		result = STATE_CRITICAL;
 	else if (usp >= 0 && usp >= (100.0 - warn_percent))
 		result = STATE_WARNING;
-	else if (warn_size >= 0 && free_swap <= warn_size)
+	else if (warn_size > 0 && (unsigned)free_swap <= warn_size)
 		result = STATE_WARNING;
 	else if (usp >= 0.0)
 		result = STATE_OK;
@@ -270,7 +322,7 @@ process_arguments (int argc, char **argv)
 			verbose++;
 			break;
 		case 'V':									/* version */
-			print_revision (progname, "$Revision$");
+			print_revision (progname, revision);
 			exit (STATE_OK);
 		case 'h':									/* help */
 			print_help ();
@@ -293,12 +345,12 @@ process_arguments (int argc, char **argv)
 
 	if (c == argc)
 		return validate_arguments ();
-	if (warn_size < 0 && is_intnonneg (argv[c]))
+	if (warn_size == 0 && is_intnonneg (argv[c]))
 		warn_size = atoi (argv[c++]);
 
 	if (c == argc)
 		return validate_arguments ();
-	if (crit_size < 0 && is_intnonneg (argv[c]))
+	if (crit_size == 0 && is_intnonneg (argv[c]))
 		crit_size = atoi (argv[c++]);
 
 	return validate_arguments ();
@@ -311,8 +363,8 @@ process_arguments (int argc, char **argv)
 int
 validate_arguments (void)
 {
-	if (warn_percent > 100 && crit_percent > 100 && warn_size < 0
-			&& crit_size < 0) {
+	if (warn_percent > 100 && crit_percent > 100 && warn_size == 0
+			&& crit_size == 0) {
 		return ERROR;
 	}
 	else if (warn_percent < crit_percent) {
@@ -325,54 +377,3 @@ validate_arguments (void)
 	}
 	return OK;
 }
-
-
-
-
-
-void
-print_usage (void)
-{
-	printf
-		("Usage:\n"
-		 " %s [-a] -w <used_percentage>%% -c <used_percentage>%%\n"
-		 " %s [-a] -w <bytes_free> -c <bytes_free>\n"
-		 " %s (-h | --help) for detailed help\n"
-		 " %s (-V | --version) for version information\n",
-		 progname, progname, progname, progname);
-}
-
-
-
-
-
-void
-print_help (void)
-{
-	print_revision (progname, REVISION);
-	printf
-		("Copyright (c) %s %s <%s>\n\n%s\n", COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
-	print_usage ();
-	printf
-		("\nOptions:\n"
-		 " -w, --warning=INTEGER\n"
-		 "   Exit with WARNING status if less than INTEGER bytes of swap space are free\n"
-		 " -w, --warning=PERCENT%%\n"
-		 "   Exit with WARNING status if less than PERCENT of swap space has been used\n"
-		 " -c, --critical=INTEGER\n"
-		 "   Exit with CRITICAL status if less than INTEGER bytes of swap space are free\n"
-		 " -c, --critical=PERCENT%%\n"
-		 "   Exit with CRITCAL status if less than PERCENT of swap space has been used\n"
-		 " -a, --allswaps\n"
-		 "    Conduct comparisons for all swap partitions, one by one\n"
-		 " -h, --help\n"
-		 "    Print detailed help screen\n"
-		 " -V, --version\n" "    Print version information\n"
-#ifdef sun
-		 "\nOn Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n"
-		 "Will be discrepencies because swap -s counts allocated swap and includes real memory\n"
-#endif
-		 "\n"
-		 );
-	support ();
-}

+ 10 - 34
plugins/check_tcp.c

@@ -99,39 +99,26 @@ print_usage (void)
 	printf (_("\
 Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
 	[-s <send string>] [-e <expect string>] [-q <quit string>]\n\
-	[-m <maximum bytes>] [-d <delay>]	[-t <timeout seconds>]\n\
+	[-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\
 	[-r <refuse state>] [-v] [-4|-6]\n"), progname);
 	printf ("       %s (-h|--help)\n", progname);
 	printf ("       %s (-V|--version)\n", progname);
 }
-
 void
 print_help (void)
 {
 	print_revision (progname, revision);
 
-	printf (_("\
-Copyright (c) %s Nagios Plugin Development Team\n\
-\t<%s>\n\n"),
-	        copyright, email);
+	printf (_(COPYRIGHT), copyright, email);
 
-	printf (_("\
-This plugin tests %s connections with the specified host.\n\n"),
+	printf (_("This plugin tests %s connections with the specified host.\n\n"),
 	        SERVICE);
 
 	print_usage ();
 
-	printf (_("\
-\nOptions:\n\
- -H, --hostname=ADDRESS\n\
-    Host name argument for servers using host headers (use numeric\n\
-    address if possible to bypass DNS lookup).\n\
- -p, --port=INTEGER\n\
-    Port number\n\
- -4, --use-ipv4\n\
-    Use IPv4 connection\n\
- -6, --use-ipv6\n\
-    Use IPv6 connection\n"));
+	printf (_(HELP_VRSN));
+
+	printf (_(HOST_PORT_46), 'p', "none");
 
 	printf (_("\
  -s, --send=STRING\n\
@@ -147,22 +134,11 @@ This plugin tests %s connections with the specified host.\n\n"),
  -m, --maxbytes=INTEGER\n\
     Close connection once more than this number of bytes are received\n\
  -d, --delay=INTEGER\n\
-    Seconds to wait between sending string and polling for response\n\
- -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"));
+    Seconds to wait between sending string and polling for response\n"));
 
-	printf (_("\
- -t, --timeout=INTEGER\n\
-    Seconds before connection times out (default: %d)\n\
- -v, --verbose\n\
-    Show details for command-line debugging (Nagios may truncate output)\n\
- -h, --help\n\
-    Print detailed help screen\n\
- -V, --version\n\
-    Print version information\n\n"),
-					DEFAULT_SOCKET_TIMEOUT);
+	printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
+
+	printf (_(VRBS));
 
 	support ();
 }