Sfoglia il codice sorgente

mark for translation

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@619 f882894a-f735-0410-b71e-b25c423dba1c
Karl DeBisschop 22 anni fa
parent
commit
1cb0499adc
3 ha cambiato i file con 115 aggiunte e 154 eliminazioni
  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_DB "template1"
 #define DEFAULT_HOST "127.0.0.1"
 #define DEFAULT_HOST "127.0.0.1"
 
 
@@ -65,6 +58,11 @@ int tcrit = DEFAULT_CRIT;
 
 
 PGconn *conn;
 PGconn *conn;
 /*PGresult   *res;*/
 /*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
 void
 print_help (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 ();
 	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_("\
 	printf (S_("\
   -d, --database=STRING\n\
   -d, --database=STRING\n\
     Database to check (default: %s)\n\
     Database to check (default: %s)\n\
@@ -150,22 +144,12 @@ print_help (void)
     Login name of user\n\
     Login name of user\n\
   -p, --password = STRING\n\
   -p, --password = STRING\n\
     Password (BIG SECURITY ISSUE)\n\n"), DEFAULT_DB);
     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\
 \n\
 This plugin tests a PostgreSQL DBMS to determine whether it is active and\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\
 accepting queries. In its current operation, it simply connects to the\n\
@@ -290,7 +274,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':     /* version */
 		case 'V':     /* version */
-			print_revision (progname, REVISION);
+			print_revision (progname, revision);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 't':     /* timeout period */
 		case 't':     /* timeout period */
 			if (!is_integer (optarg))
 			if (!is_integer (optarg))

+ 82 - 81
plugins/check_swap.c

@@ -30,12 +30,11 @@
 #include "utils.h"
 #include "utils.h"
 
 
 const char *progname = "check_swap";
 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 process_arguments (int argc, char **argv);
 int validate_arguments (void);
 int validate_arguments (void);
 void print_usage (void);
 void print_usage (void);
@@ -52,16 +51,68 @@ int allswaps;
 int sun = 0;	/* defined by compiler if it is a sun solaris system */
 int sun = 0;	/* defined by compiler if it is a sun solaris system */
 #endif
 #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
 int
 main (int argc, char **argv)
 main (int argc, char **argv)
 {
 {
 	int percent_used, percent;
 	int percent_used, percent;
 	long unsigned int total_swap = 0, used_swap = 0, free_swap = 0;
 	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;
 	int result = STATE_OK;
 	char input_buffer[MAX_INPUT_BUFFER];
 	char input_buffer[MAX_INPUT_BUFFER];
 #ifdef HAVE_SWAP
 #ifdef HAVE_SWAP
+	int conv_factor;		/* Convert to MBs */
 	char *temp_buffer;
 	char *temp_buffer;
 	char *swap_command;
 	char *swap_command;
 	char *swap_format;
 	char *swap_format;
@@ -78,11 +129,11 @@ main (int argc, char **argv)
 #ifdef HAVE_PROC_MEMINFO
 #ifdef HAVE_PROC_MEMINFO
 	fp = fopen (PROC_MEMINFO, "r");
 	fp = fopen (PROC_MEMINFO, "r");
 	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
 	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")) {
 		    strstr (str, "Swap")) {
-			total = total / 1048576;
-			used = used / 1048576;
-			free = free / 1048576;
+			dsktotal = dsktotal / 1048576;
+			dskused = dskused / 1048576;
+			dskfree = dskfree / 1048576;
 #endif
 #endif
 #ifdef HAVE_SWAP
 #ifdef HAVE_SWAP
 	if (!allswaps && sun) {
 	if (!allswaps && sun) {
@@ -118,7 +169,7 @@ main (int argc, char **argv)
 		while (temp_buffer) {
 		while (temp_buffer) {
 			if (strstr (temp_buffer, "blocks"))
 			if (strstr (temp_buffer, "blocks"))
 				sprintf (str, "%s %s", str, "%f");
 				sprintf (str, "%s %s", str, "%f");
-			else if (strstr (temp_buffer, "free"))
+			else if (strstr (temp_buffer, "dskfree"))
 				sprintf (str, "%s %s", str, "%f");
 				sprintf (str, "%s %s", str, "%f");
 			else
 			else
 				sprintf (str, "%s %s", str, "%*s");
 				sprintf (str, "%s %s", str, "%*s");
@@ -133,23 +184,23 @@ main (int argc, char **argv)
 		total_swap = used_swap + free_swap;
 		total_swap = used_swap + free_swap;
 	} else {
 	} else {
 		while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
 		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)
 			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
 #endif
-			total_swap += total;
-			used_swap += used;
-			free_swap += free;
+			total_swap += dsktotal;
+			used_swap += dskused;
+			free_swap += dskfree;
 			if (allswaps) {
 			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)
 				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
 #endif
 
 
 	terminate (result, "SWAP %s:%s\n", state_text (result), status);
 	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;
 	int result = STATE_UNKNOWN;
 	if (usp >= 0 && usp >= (100.0 - crit_percent))
 	if (usp >= 0 && usp >= (100.0 - crit_percent))
 		result = STATE_CRITICAL;
 		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;
 		result = STATE_CRITICAL;
 	else if (usp >= 0 && usp >= (100.0 - warn_percent))
 	else if (usp >= 0 && usp >= (100.0 - warn_percent))
 		result = STATE_WARNING;
 		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;
 		result = STATE_WARNING;
 	else if (usp >= 0.0)
 	else if (usp >= 0.0)
 		result = STATE_OK;
 		result = STATE_OK;
@@ -270,7 +322,7 @@ process_arguments (int argc, char **argv)
 			verbose++;
 			verbose++;
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (progname, "$Revision$");
+			print_revision (progname, revision);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -293,12 +345,12 @@ process_arguments (int argc, char **argv)
 
 
 	if (c == argc)
 	if (c == argc)
 		return validate_arguments ();
 		return validate_arguments ();
-	if (warn_size < 0 && is_intnonneg (argv[c]))
+	if (warn_size == 0 && is_intnonneg (argv[c]))
 		warn_size = atoi (argv[c++]);
 		warn_size = atoi (argv[c++]);
 
 
 	if (c == argc)
 	if (c == argc)
 		return validate_arguments ();
 		return validate_arguments ();
-	if (crit_size < 0 && is_intnonneg (argv[c]))
+	if (crit_size == 0 && is_intnonneg (argv[c]))
 		crit_size = atoi (argv[c++]);
 		crit_size = atoi (argv[c++]);
 
 
 	return validate_arguments ();
 	return validate_arguments ();
@@ -311,8 +363,8 @@ process_arguments (int argc, char **argv)
 int
 int
 validate_arguments (void)
 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;
 		return ERROR;
 	}
 	}
 	else if (warn_percent < crit_percent) {
 	else if (warn_percent < crit_percent) {
@@ -325,54 +377,3 @@ validate_arguments (void)
 	}
 	}
 	return OK;
 	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 (_("\
 	printf (_("\
 Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
 Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
 	[-s <send string>] [-e <expect string>] [-q <quit string>]\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);
 	[-r <refuse state>] [-v] [-4|-6]\n"), progname);
 	printf ("       %s (-h|--help)\n", progname);
 	printf ("       %s (-h|--help)\n", progname);
 	printf ("       %s (-V|--version)\n", progname);
 	printf ("       %s (-V|--version)\n", progname);
 }
 }
-
 void
 void
 print_help (void)
 print_help (void)
 {
 {
 	print_revision (progname, revision);
 	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);
 	        SERVICE);
 
 
 	print_usage ();
 	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 (_("\
 	printf (_("\
  -s, --send=STRING\n\
  -s, --send=STRING\n\
@@ -147,22 +134,11 @@ This plugin tests %s connections with the specified host.\n\n"),
  -m, --maxbytes=INTEGER\n\
  -m, --maxbytes=INTEGER\n\
     Close connection once more than this number of bytes are received\n\
     Close connection once more than this number of bytes are received\n\
  -d, --delay=INTEGER\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 ();
 	support ();
 }
 }