[Nagiosplug-checkins] CVS: nagiosplug/plugins check_load.c,1.7,1.8

Karl DeBisschop kdebisschop at users.sourceforge.net
Sat Aug 2 23:20:03 CEST 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv20914

Modified Files:
	check_load.c 
Log Message:
markup for translation

Index: check_load.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_load.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** check_load.c	11 Mar 2003 22:22:10 -0000	1.7
--- check_load.c	3 Aug 2003 06:19:51 -0000	1.8
***************
*** 25,31 ****
   *****************************************************************************/
  
! #include "config.h"
  #include "common.h"
  #include "utils.h"
  
  #ifdef HAVE_SYS_LOADAVG_H
--- 25,68 ----
   *****************************************************************************/
  
! const char *progname = "check_load";
! const char *revision = "$Revision$";
! const char *copyright = "1999-2003";
! const char *email = "nagiosplug-devel at lists.sourceforge.net";
! 
  #include "common.h"
  #include "utils.h"
+ #include "popen.h"
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("Usage: %s -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n"),
+ 	        progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
+ }
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida at linux.ime.usp.br>\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("This plugin tests the current system load average.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+  -w, --warning=WLOAD1,WLOAD5,WLOAD15\n\
+    Exit with WARNING status if load average exceeds WLOADn\n\
+  -c, --critical=CLOAD1,CLOAD5,CLOAD15\n\
+    Exit with CRITICAL status if load average exceed CLOADn\n\n\
+ the load average format is the same used by \"uptime\" and \"w\"\n\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
  
  #ifdef HAVE_SYS_LOADAVG_H
***************
*** 40,54 ****
  #endif /* !defined LOADAVG_1MIN */
  
- #include "popen.h"
- #ifdef HAVE_PROC_LOADAVG
- 
- #endif
- 
- const char *progname = "check_load";
  
  int process_arguments (int argc, char **argv);
  int validate_arguments (void);
- void print_usage (void);
- void print_help (void);
  
  float wload1 = -1, wload5 = -1, wload15 = -1;
--- 77,83 ----
***************
*** 87,91 ****
  	fp = fopen (PROC_LOADAVG, "r");
  	if (fp == NULL) {
! 		printf ("Error opening %s\n", PROC_LOADAVG);
  		return STATE_UNKNOWN;
  	}
--- 116,120 ----
  	fp = fopen (PROC_LOADAVG, "r");
  	if (fp == NULL) {
! 		printf (_("Error opening %s\n"), PROC_LOADAVG);
  		return STATE_UNKNOWN;
  	}
***************
*** 106,122 ****
  	child_process = spopen (PATH_TO_UPTIME);
  	if (child_process == NULL) {
! 		printf ("Error opening %s\n", PATH_TO_UPTIME);
  		return STATE_UNKNOWN;
  	}
  	child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
  	if (child_stderr == NULL) {
! 		printf ("Could not open stderr for %s\n", PATH_TO_UPTIME);
  	}
  	fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
! 	sscanf (input_buffer, "%*[^l]load average: %f, %f, %f", &la1, &la5, &la15);
  
  	result = spclose (child_process);
  	if (result) {
! 		printf ("Error code %d returned in %s\n", result, PATH_TO_UPTIME);
  		return STATE_UNKNOWN;
  	}
--- 135,151 ----
  	child_process = spopen (PATH_TO_UPTIME);
  	if (child_process == NULL) {
! 		printf (_("Error opening %s\n"), PATH_TO_UPTIME);
  		return STATE_UNKNOWN;
  	}
  	child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
  	if (child_stderr == NULL) {
! 		printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME);
  	}
  	fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
! 	sscanf (input_buffer, "%*[^l]load average: %f, %f, %f"), &la1, &la5, &la15);
  
  	result = spclose (child_process);
  	if (result) {
! 		printf (_("Error code %d returned in %s\n"), result, PATH_TO_UPTIME);
  		return STATE_UNKNOWN;
  	}
***************
*** 125,146 ****
  	if ((la1 == -1) || (la5 == -1) || (la15 == -1)) {
  #if HAVE_GETLOADAVG==1
! 		printf ("Error in getloadavg()\n");
  #elif HAVE_PROC_LOADAVG==1
! 		printf ("Error processing %s\n", PROC_LOADAVG);
  #else
! 		printf ("Error processing %s\n", PATH_TO_UPTIME);
  #endif
  		return STATE_UNKNOWN;
  	}
! 	asprintf(&status_line, "load average: %.2f, %.2f, %.2f", la1, la5, la15);
  	if ((la1 >= cload1) || (la5 >= cload5) || (la15 >= cload15)) {
! 		printf("CRITICAL - %s\n", status_line);
  		return STATE_CRITICAL;
  	}
  	if ((la1 >= wload1) || (la5 >= wload5) || (la15 >= wload15)) {
! 		printf ("WARNING - %s\n", status_line);
  		return STATE_WARNING;
  	}
! 	printf ("OK - %s\n", status_line);
  	return STATE_OK;
  }
--- 154,175 ----
  	if ((la1 == -1) || (la5 == -1) || (la15 == -1)) {
  #if HAVE_GETLOADAVG==1
! 		printf (_("Error in getloadavg()\n"));
  #elif HAVE_PROC_LOADAVG==1
! 		printf (_("Error processing %s\n"), PROC_LOADAVG);
  #else
! 		printf (_("Error processing %s\n"), PATH_TO_UPTIME);
  #endif
  		return STATE_UNKNOWN;
  	}
! 	asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
  	if ((la1 >= cload1) || (la5 >= cload5) || (la15 >= cload15)) {
! 		printf(_("CRITICAL - %s\n"), status_line);
  		return STATE_CRITICAL;
  	}
  	if ((la1 >= wload1) || (la5 >= wload5) || (la15 >= wload15)) {
! 		printf (_("WARNING - %s\n"), status_line);
  		return STATE_WARNING;
  	}
! 	printf (_("OK - %s\n"), status_line);
  	return STATE_OK;
  }
***************
*** 189,193 ****
  				break;
  			else
! 				usage ("Warning threshold must be float or float triplet!\n");
  			break;
  		case 'c':									/* critical time threshold */
--- 218,222 ----
  				break;
  			else
! 				usage (_("Warning threshold must be float or float triplet!\n"));
  			break;
  		case 'c':									/* critical time threshold */
***************
*** 205,209 ****
  				break;
  			else
! 				usage ("Critical threshold must be float or float triplet!\n");
  			break;
  		case 'V':									/* version */
--- 234,238 ----
  				break;
  			else
! 				usage (_("Critical threshold must be float or float triplet!\n"));
  			break;
  		case 'V':									/* version */
***************
*** 214,218 ****
  			exit (STATE_OK);
  		case '?':									/* help */
! 			usage ("Invalid argument\n");
  		}
  	}
--- 243,247 ----
  			exit (STATE_OK);
  		case '?':									/* help */
! 			usage (_("Invalid argument\n"));
  		}
  	}
***************
*** 260,319 ****
  {
  	if (wload1 < 0)
! 		usage ("Warning threshold for 1-minute load average is not specified\n");
  	if (wload5 < 0)
! 		usage ("Warning threshold for 5-minute load average is not specified\n");
  	if (wload15 < 0)
! 		usage ("Warning threshold for 15-minute load average is not specified\n");
  	if (cload1 < 0)
! 		usage ("Critical threshold for 1-minute load average is not specified\n");
  	if (cload5 < 0)
! 		usage ("Critical threshold for 5-minute load average is not specified\n");
  	if (cload15 < 0)
! 		usage ("Critical threshold for 15-minute load average is not specified\n");
  	if (wload1 > cload1)
! 		usage ("Parameter inconsistency: 1-minute \"warning load\" greater than \"critical load\".\n");
  	if (wload5 > cload5)
! 		usage ("Parameter inconsistency: 5-minute \"warning load\" greater than \"critical load\".\n");
  	if (wload15 > cload15)
! 		usage ("Parameter inconsistency: 15-minute \"warning load\" greater than \"critical load\".\n");
  	return OK;
- }
- 
- 
- 
- 
- 
- void
- print_usage (void)
- {
- 	printf
- 		("Usage: check_load -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n"
- 		 "       check_load --version\n" "       check_load --help\n");
- }
- 
- 
- 
- 
- 
- void
- print_help (void)
- {
- 	print_revision (progname, "$Revision$");
- 	printf
- 		("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida at linux.ime.usp.br>\n"
- 		 "Copyright (c) 2000 Karl DeBisschop\n\n"
- 		 "This plugin tests the current system load average.\n\n");
- 	print_usage ();
- 	printf
- 		("\nOptions:\n"
- 		 " -w, --warning=WLOAD1,WLOAD5,WLOAD15\n"
- 		 "   Exit with WARNING status if load average exceeds WLOADn\n"
- 		 " -c, --critical=CLOAD1,CLOAD5,CLOAD15\n"
- 		 "   Exit with CRITICAL status if load average exceed CLOADn\n"
- 		 " -h, --help\n"
- 		 "    Print detailed help screen\n"
- 		 " -V, --version\n"
- 		 "    Print version information\n\n"
- 		 "the load average format is the same used by \"uptime\" and \"w\"\n\n");
- 	support ();
  }
--- 289,309 ----
  {
  	if (wload1 < 0)
! 		usage (_("Warning threshold for 1-minute load average is not specified\n"));
  	if (wload5 < 0)
! 		usage (_("Warning threshold for 5-minute load average is not specified\n"));
  	if (wload15 < 0)
! 		usage (_("Warning threshold for 15-minute load average is not specified\n"));
  	if (cload1 < 0)
! 		usage (_("Critical threshold for 1-minute load average is not specified\n"));
  	if (cload5 < 0)
! 		usage (_("Critical threshold for 5-minute load average is not specified\n"));
  	if (cload15 < 0)
! 		usage (_("Critical threshold for 15-minute load average is not specified\n"));
  	if (wload1 > cload1)
! 		usage (_("Parameter inconsistency: 1-minute \"warning load\" greater than \"critical load\".\n"));
  	if (wload5 > cload5)
! 		usage (_("Parameter inconsistency: 5-minute \"warning load\" greater than \"critical load\".\n"));
  	if (wload15 > cload15)
! 		usage (_("Parameter inconsistency: 15-minute \"warning load\" greater than \"critical load\".\n"));
  	return OK;
  }





More information about the Commits mailing list