4
0
Эх сурвалжийг харах

use usage2 function

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@781 f882894a-f735-0410-b71e-b25c423dba1c
Karl DeBisschop 22 жил өмнө
parent
commit
d4bda4c91b

+ 9 - 27
plugins/check_procs.c

@@ -260,7 +260,7 @@ main (int argc, char **argv)
 			printf (_("%d crit, %d warn out of "), crit, warn);
 			printf (_("%d crit, %d warn out of "), crit, warn);
 		}
 		}
 	} 
 	} 
-	printf (ngettext ("%d process", "%d processes", procs), procs);
+	printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs);
 	
 	
 	if (strcmp(fmt,"") != 0) {
 	if (strcmp(fmt,"") != 0) {
 		printf (_(" with %s"), fmt);
 		printf (_(" with %s"), fmt);
@@ -361,10 +361,7 @@ process_arguments (int argc, char **argv)
 				options |= PPID;
 				options |= PPID;
 				break;
 				break;
 			}
 			}
-			printf (_("%s: Parent Process ID must be an integer!\n\n"),
-			        progname);
-			print_usage ();
-			exit (STATE_UNKNOWN);
+			usage2 (_("%s: Parent Process ID must be an integer!\n\n"),  progname);
 		case 's':									/* status */
 		case 's':									/* status */
 			if (statopts)
 			if (statopts)
 				break;
 				break;
@@ -378,20 +375,14 @@ process_arguments (int argc, char **argv)
 				uid = atoi (optarg);
 				uid = atoi (optarg);
 				pw = getpwuid ((uid_t) uid);
 				pw = getpwuid ((uid_t) uid);
 				/*  check to be sure user exists */
 				/*  check to be sure user exists */
-				if (pw == NULL) {
-					printf (_("UID %d was not found\n"), uid);
-					print_usage ();
-					exit (STATE_UNKNOWN);
-				}
+				if (pw == NULL)
+					usage2 (_("UID %d was not found\n"), uid);
 			}
 			}
 			else {
 			else {
 				pw = getpwnam (optarg);
 				pw = getpwnam (optarg);
 				/*  check to be sure user exists */
 				/*  check to be sure user exists */
-				if (pw == NULL) {
-					printf (_("User name %s was not found\n"), optarg);
-					print_usage ();
-					exit (STATE_UNKNOWN);
-				}
+				if (pw == NULL)
+					usage2 (_("User name %s was not found\n"), optarg);
 				/*  then get uid */
 				/*  then get uid */
 				uid = pw->pw_uid;
 				uid = pw->pw_uid;
 			}
 			}
@@ -423,20 +414,14 @@ process_arguments (int argc, char **argv)
 				options |= RSS;
 				options |= RSS;
 				break;
 				break;
 			}
 			}
-			printf (_("%s: RSS must be an integer!\n\n"),
-			        progname);
-			print_usage ();
-			exit (STATE_UNKNOWN);
+			usage2 (_("%s: RSS must be an integer!\n\n"), progname);
 		case 'z':					/* VSZ */
 		case 'z':					/* VSZ */
 			if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) {
 			if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) {
 				asprintf (&fmt, _("%s%sVSZ >= %d"), (fmt ? fmt : ""), (options ? ", " : ""), vsz);
 				asprintf (&fmt, _("%s%sVSZ >= %d"), (fmt ? fmt : ""), (options ? ", " : ""), vsz);
 				options |= VSZ;
 				options |= VSZ;
 				break;
 				break;
 			}
 			}
-			printf (_("%s: VSZ must be an integer!\n\n"),
-			        progname);
-			print_usage ();
-			exit (STATE_UNKNOWN);
+			usage2 (_("%s: VSZ must be an integer!\n\n"), progname);
 		case 'P':					/* PCPU */
 		case 'P':					/* PCPU */
 			/* TODO: -P 1.5.5 is accepted */
 			/* TODO: -P 1.5.5 is accepted */
 			if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) {
 			if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) {
@@ -444,10 +429,7 @@ process_arguments (int argc, char **argv)
 				options |= PCPU;
 				options |= PCPU;
 				break;
 				break;
 			}
 			}
-			printf (_("%s: PCPU must be a float!\n\n"),
-			        progname);
-			print_usage ();
-			exit (STATE_UNKNOWN);
+			usage2 (_("%s: PCPU must be a float!\n\n"), progname);
 		case 'm':
 		case 'm':
 			asprintf (&metric_name, "%s", optarg);
 			asprintf (&metric_name, "%s", optarg);
 			if ( strcmp(optarg, "PROCS") == 0) {
 			if ( strcmp(optarg, "PROCS") == 0) {