Browse Source

- bindtextdomain for gettext, a few other smale cleanups here and there

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@690 f882894a-f735-0410-b71e-b25c423dba1c
Karl DeBisschop 22 năm trước cách đây
mục cha
commit
22bd672d19

+ 21 - 14
plugins/check_by_ssh.c

@@ -42,11 +42,6 @@ char **service;
 int passive = FALSE;
 int verbose = FALSE;
 
-
-
-
-
-
 int
 main (int argc, char **argv)
 {
@@ -61,8 +56,13 @@ main (int argc, char **argv)
 	time_t local_time;
 	FILE *fp = NULL;
 
-	asprintf (&remotecmd, "%s", "");
-	asprintf (&comm, "%s", SSH_COMMAND);
+	remotecmd = strdup ("");
+	comm = strdup (SSH_COMMAND);
+	result_text = strdup ("");
+
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
 
 	/* process arguments */
 	if (process_arguments (argc, argv) == ERROR)
@@ -71,7 +71,7 @@ main (int argc, char **argv)
 
 	/* Set signal handling and alarm timeout */
 	if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
-		printf ("Cannot catch SIGALRM");
+		printf (_("Cannot catch SIGALRM"));
 		return STATE_UNKNOWN;
 	}
 	alarm (timeout_interval);
@@ -97,7 +97,7 @@ main (int argc, char **argv)
 	}
 
 
-	/* get results from remote command */
+	/* build up results from remote command in result_text */
 	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
 		asprintf (&result_text, "%s%s", result_text, input_buffer);
 
@@ -105,6 +105,8 @@ main (int argc, char **argv)
 	/* WARNING if output found on stderr */
 	if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
 		printf ("%s\n", input_buffer);
+		while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
+			printf ("%s\n", input_buffer);
 		return STATE_WARNING;
 	}
 	(void) fclose (child_stderr);
@@ -122,10 +124,10 @@ main (int argc, char **argv)
 			exit (STATE_UNKNOWN);
 		}
 
-		time (&local_time);
+		local_time = time (NULL);
 		commands = 0;
 		while (result_text && strlen(result_text) > 0) {
-			status_text = strstr (result_text, _("STATUS CODE: "));
+			status_text = strstr (result_text, "STATUS CODE: ");
 			if (status_text == NULL) {
 				printf ("%s", result_text);
 				return result;
@@ -136,7 +138,7 @@ main (int argc, char **argv)
 			if (eol != NULL)
 				eol[0] = 0;
 			if (service[commands] && status_text
-					&& sscanf (status_text, _("STATUS CODE: %d"), &cresult) == 1) {
+					&& sscanf (status_text, "STATUS CODE: %d", &cresult) == 1) {
 				fprintf (fp, _("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n"),
 								 (int) local_time, host_shortname, service[commands++], cresult,
 								 output);
@@ -145,6 +147,7 @@ main (int argc, char **argv)
 
 	}
 
+
 	/* print the first line from the remote command */
 	else {
  		eol = strpbrk (result_text, "\r\n");
@@ -153,7 +156,8 @@ main (int argc, char **argv)
  		printf ("%s\n", result_text);
 	}
 
-	/* return error status from remote command */
+
+	/* return error status from remote command */	
 	return result;
 }
 
@@ -222,7 +226,8 @@ process_arguments (int argc, char **argv)
 		case 't':									/* timeout period */
 			if (!is_integer (optarg))
 				usage2 (_("timeout interval must be an integer"), optarg);
-			timeout_interval = atoi (optarg);
+			else
+				timeout_interval = atoi (optarg);
 			break;
 		case 'H':									/* host */
 			if (!is_host (optarg))
@@ -382,6 +387,8 @@ execute additional commands as proxy\n"));
 To use passive mode, provide multiple '-C' options, and provide\n\
 all of -O, -s, and -n options (servicelist order must match '-C'\n\
 options)\n"));
+
+	printf (_(UT_SUPPORT));
 }
 
 

+ 5 - 5
plugins/check_dig.c

@@ -42,11 +42,6 @@ int server_port = DEFAULT_PORT;
 int warning_interval = -1;
 int critical_interval = -1;
 
-
-
-
-
-
 int
 main (int argc, char **argv)
 {
@@ -57,6 +52,10 @@ main (int argc, char **argv)
 
 	output = strdup ("");
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	/* Set signal handling and alarm */
 	if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR)
 		usage (_("Cannot catch SIGALRM\n"));
@@ -280,6 +279,7 @@ print_help (void)
 
 	print_revision (progname, revision);
 
+	printf (_("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n"));
 	printf (_(COPYRIGHT), copyright, email);
 
 	printf (_("Test the DNS service on the specified host using dig\n\n"));

+ 4 - 0
plugins/check_disk.c

@@ -151,6 +151,10 @@ main (int argc, char **argv)
 	output = strdup ("");
 	details = strdup ("");
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	mount_list = read_filesystem_list (0);
 
 	if (process_arguments (argc, argv) != OK)

+ 5 - 0
plugins/check_dns.c

@@ -82,6 +82,10 @@ main (int argc, char **argv)
 	struct timeval tv;
 	int multi_address;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	/* Set signal handling and alarm */
 	if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
 		printf (_("Cannot catch SIGALRM"));
@@ -398,6 +402,7 @@ print_help (void)
 {
 	print_revision (progname, revision);
 
+	printf (_("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"));
 	printf (_(COPYRIGHT), copyright, email);
 
 	print_usage ();

+ 4 - 0
plugins/check_dummy.c

@@ -34,6 +34,10 @@ main (int argc, char **argv)
 {
 	int result;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (argc != 2)
 		usage (_("Incorrect number of arguments supplied\n"));
 	else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {

+ 4 - 0
plugins/check_fping.c

@@ -69,6 +69,10 @@ main (int argc, char **argv)
 	char *input_buffer = NULL;
 	input_buffer = malloc (MAX_INPUT_BUFFER);
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage (_("Could not parse arguments\n"));
 

+ 4 - 0
plugins/check_game.c

@@ -60,6 +60,10 @@ main (int argc, char **argv)
 	char *p, *ret[QSTAT_MAX_RETURN_ARGS];
 	int i;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	result = process_arguments (argc, argv);
 
 	if (result != OK) {

+ 5 - 0
plugins/check_hpjd.c

@@ -79,6 +79,10 @@ main (int argc, char **argv)
 
 	errmsg = malloc(MAX_INPUT_BUFFER);
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) != OK)
 		usage (_("Invalid command arguments supplied\n"));
 
@@ -374,6 +378,7 @@ print_help (void)
 {
 	print_revision (progname, revision);
 
+	printf (_("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"));
 	printf (_(COPYRIGHT), copyright, email);
 
 	printf (_("\

+ 1 - 1
plugins/check_http.c

@@ -815,7 +815,7 @@ redir (char *pos, char *status_line)
 			else if (sscanf (pos, HD5, url) == 1) {
 				/* relative url */
 				if ((url[0] != '/')) {
-					if (x = strrchr(url, '/'))
+					if ((x = strrchr(url, '/')))
 						*x = '\0';
 					asprintf (&server_url, "%s/%s", server_url, url);
 				}

+ 4 - 0
plugins/check_ide-smart.c

@@ -396,6 +396,10 @@ main (int argc, char *argv[])
 		{"version", no_argument, 0, 'V'}, {0, 0, 0, 0} 
 	};
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	while (1) {
 		
 		o = getopt_long (argc, argv, "+d:iq10nhV", longopts, &longindex);

+ 4 - 0
plugins/check_ldap.c

@@ -64,6 +64,10 @@ main (int argc, char *argv[])
 	int t_diff;
 	time_t time0, time1;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage (_("check_ldap: could not parse arguments\n"));
 

+ 4 - 0
plugins/check_load.c

@@ -71,6 +71,10 @@ main (int argc, char **argv)
 
 	float la1, la5, la15;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage ("failed processing arguments\n");
 

+ 4 - 0
plugins/check_mrtg.c

@@ -53,6 +53,10 @@ main (int argc, char **argv)
 	unsigned long maximum_value_rate = 0L;
 	unsigned long value_rate = 0L;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) != OK)
 		usage (_("Invalid command arguments supplied\n"));
 

+ 4 - 0
plugins/check_mysql.c

@@ -43,6 +43,10 @@ main (int argc, char **argv)
 	MYSQL mysql;
 	char *result = NULL;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) != OK)
 		usage (_("Invalid command arguments supplied\n"));
 

+ 4 - 0
plugins/check_nagios.c

@@ -56,6 +56,10 @@ main (int argc, char **argv)
 	char *procargs;
 	int pos, cols;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage (_("Could not parse arguments\n"));
 

+ 4 - 0
plugins/check_nt.c

@@ -96,6 +96,10 @@ int main(int argc, char **argv){
 	int uphours=0;
 	int upminutes=0;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if(process_arguments(argc,argv)==ERROR)
 		usage(_("Could not parse arguments\n"));
 

+ 4 - 0
plugins/check_nwstat.c

@@ -117,6 +117,10 @@ main(int argc, char **argv) {
 	unsigned long sap_entries=0;
 	char uptime[MAX_INPUT_BUFFER];
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments(argc,argv)==ERROR)
 		usage(_("Could not parse arguments\n"));
 

+ 4 - 0
plugins/check_overcr.c

@@ -79,6 +79,10 @@ main (int argc, char **argv)
 	int uptime_hours = 0;
 	int uptime_minutes = 0;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage ("Could not parse arguments\n");
 

+ 4 - 0
plugins/check_pgsql.c

@@ -128,6 +128,10 @@ main (int argc, char **argv)
 	pgoptions = NULL;  /* special options to start up the backend server */
 	pgtty = NULL;      /* debugging tty for the backend server */
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage ("Could not parse arguments");
 

+ 4 - 0
plugins/check_ping.c

@@ -70,6 +70,10 @@ main (int argc, char **argv)
 	int this_result = STATE_UNKNOWN;
 	int i;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	addresses = malloc ((size_t)max_addr);
 
 	if (process_arguments (argc, argv) == ERROR)

+ 4 - 0
plugins/check_procs.c

@@ -103,6 +103,10 @@ main (int argc, char **argv)
 
 	int result = STATE_UNKNOWN;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	asprintf (&metric_name, "PROCS");
 	metric = METRIC_PROCS;
 

+ 4 - 0
plugins/check_radius.c

@@ -103,6 +103,10 @@ main (int argc, char **argv)
 	UINT4 client_id;
 	char *str;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage (_("Could not parse arguments\n"));
 

+ 4 - 0
plugins/check_real.c

@@ -61,6 +61,10 @@ main (int argc, char **argv)
 	char buffer[MAX_INPUT_BUFFER];
 	char *status_line = NULL;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) != OK)
 		usage (_("Invalid command arguments supplied\n"));
 

+ 4 - 0
plugins/check_smtp.c

@@ -66,6 +66,10 @@ main (int argc, char **argv)
 	char *helocmd = NULL;
 	struct timeval tv;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) != OK)
 		usage (_("Invalid command arguments supplied\n"));
 

+ 6 - 1
plugins/check_snmp.c

@@ -137,6 +137,10 @@ main (int argc, char **argv)
 	char *p2 = NULL;
 	char *show = NULL;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	labels = malloc (labels_size);
 	unitv = malloc (unitv_size);
 	for (i = 0; i < MAX_OIDS; i++)
@@ -443,7 +447,8 @@ process_arguments (int argc, char **argv)
 		case 't':	/* timeout period */
 			if (!is_integer (optarg))
 				usage2 (_("Timeout Interval must be an integer"), optarg);
-			timeout_interval = atoi (optarg);
+			else
+				timeout_interval = atoi (optarg);
 			break;
 
 	/* Test parameters */

+ 4 - 0
plugins/check_ssh.c

@@ -48,6 +48,10 @@ main (int argc, char **argv)
 {
 	int result;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage (_("Could not parse arguments\n"));
 

+ 6 - 4
plugins/check_swap.c

@@ -71,6 +71,10 @@ main (int argc, char **argv)
 	char str[32];
 	char *status;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	status = strdup("");
 
 	if (process_arguments (argc, argv) != OK)
@@ -205,8 +209,6 @@ int
 process_arguments (int argc, char **argv)
 {
 	int c = 0;  /* option character */
-	int wc = 0; /* warning counter  */
-	int cc = 0; /* critical counter */
 
 	int option = 0;
 	static struct option longopts[] = {
@@ -229,7 +231,7 @@ process_arguments (int argc, char **argv)
 			break;
 
 		switch (c) {
-		case 'w':									/* warning time threshold */
+		case 'w':									/* warning size threshold */
 			if (is_intnonneg (optarg)) {
 				warn_size = atoi (optarg);
 				break;
@@ -246,7 +248,7 @@ process_arguments (int argc, char **argv)
 			else {
 				usage (_("Warning threshold must be integer or percentage!\n"));
 			}
-		case 'c':									/* critical time threshold */
+		case 'c':									/* critical size threshold */
 			if (is_intnonneg (optarg)) {
 				crit_size = atoi (optarg);
 				break;

+ 4 - 2
plugins/check_tcp.c

@@ -16,8 +16,8 @@
 
 *****************************************************************************/
 
-/* progname changes depending on symlink called */
-char *progname = "check_tcp";
+/* progname "check_tcp" changes depending on symlink called */
+char *progname;
 const char *revision = "$Revision$";
 const char *copyright = "1999-2003";
 const char *email = "nagiosplug-devel@lists.sourceforge.net";
@@ -198,6 +198,7 @@ main (int argc, char **argv)
 		PORT = 119;
 	}
 	else {
+		progname = strdup ("check_tcp");
 		usage (_("ERROR: Generic check_tcp called with unknown service\n"));
 	}
 
@@ -592,6 +593,7 @@ print_help (void)
 {
 	print_revision (progname, revision);
 
+	printf (_("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"));
 	printf (_(COPYRIGHT), copyright, email);
 
 	printf (_("This plugin tests %s connections with the specified host.\n\n"),

+ 4 - 0
plugins/check_time.c

@@ -55,6 +55,10 @@ main (int argc, char **argv)
 	int sd;
 	int result;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) != OK)
 		usage (_("Invalid command arguments supplied\n"));
 

+ 4 - 0
plugins/check_udp.c

@@ -45,6 +45,10 @@ main (int argc, char **argv)
 	int result;
 	char recv_buffer[MAX_INPUT_BUFFER];
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage ("\n");
 

+ 5 - 1
plugins/check_ups.c

@@ -79,8 +79,12 @@ main (int argc, char **argv)
 	int result = STATE_OK;
 	char *message;
 	char temp_buffer[MAX_INPUT_BUFFER];
-
 	double ups_utility_deviation = 0.0;
+
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	ups_status = strdup ("N/A");
 
 	if (process_arguments (argc, argv) != OK)

+ 4 - 0
plugins/check_users.c

@@ -41,6 +41,10 @@ main (int argc, char **argv)
 	int result = STATE_OK;
 	char input_buffer[MAX_INPUT_BUFFER];
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage (_("Could not parse arguments\n"));
 

+ 4 - 0
plugins/negate.c

@@ -75,6 +75,10 @@ main (int argc, char **argv)
 	int found = 0, result = STATE_UNKNOWN;
 	char *buf;
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	if (process_arguments (argc, argv) == ERROR)
 		usage (_("Could not parse arguments\n"));
 

+ 4 - 0
plugins/urlize.c

@@ -45,6 +45,10 @@ main (int argc, char **argv)
 		{0, 0, 0, 0}
 	};
 
+	setlocale (LC_ALL, "");
+	bindtextdomain (PACKAGE, LOCALEDIR);
+	textdomain (PACKAGE);
+
 	while (1) {
 		c = getopt_long (argc, argv, "+hVu:", longopts, &option);