[Nagiosplug-devel] check_load behaves inconsistent | use without setting thresholds

Christian Schneemann cschneemann at suse.de
Mon May 19 17:55:50 CEST 2008


On Monday May 19 2008 02:20:00 pm Christian Schneemann wrote:
> Hi,
> I want to use check_load only for performance data, no warning or critical
> threshold should be set. Ok, that's not possible at the moment, because the
> function process_arguments checks if argc < 2. This is also true if just
> the -r option is set and that results in a critical return value. Shouldn't
> this also be prohibited without any thresholds?
>
> I would prefere a option to switch the test for thresholds to off and
> return a "OK" if set to use the functinality of the test for creating
> performance data.
> Any comments on that?
Ok, here a quick'n'dirty patch introducing a new switch: -p

--- plugins/check_load.c
+++ plugins/check_load.c
@@ -72,6 +72,7 @@
 
 char *status_line;
 int take_into_account_cpus = 0;
+int perfdataonly = 0;
 
 static void
 get_threshold(char *arg, double *th)
@@ -192,12 +193,15 @@
 
 	asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
 
-	for(i = 0; i < 3; i++) {
-		if(la[i] > cload[i]) {
-			result = STATE_CRITICAL;
-			break;
+	if (!perfdataonly) /*don't compare the measured values with thresholds if 
perfdataonly is set */
+	{
+		for(i = 0; i < 3; i++) {
+			if(la[i] > cload[i]) {
+				result = STATE_CRITICAL;
+				break;
+			}
+			else if(la[i] > wload[i]) result = STATE_WARNING;
 		}
-		else if(la[i] > wload[i]) result = STATE_WARNING;
 	}
 
 	printf("%s - %s|", state_text(result), status_line);
@@ -222,6 +226,7 @@
 		{"percpu", no_argument, 0, 'r'},
 		{"version", no_argument, 0, 'V'},
 		{"help", no_argument, 0, 'h'},
+		{"perfdataonly", no_argument, 0, 'p'},
 		{0, 0, 0, 0}
 	};
 
@@ -229,7 +234,7 @@
 		return ERROR;
 
 	while (1) {
-		c = getopt_long (argc, argv, "Vhrc:w:", longopts, &option);
+		c = getopt_long (argc, argv, "Vhrpc:w:", longopts, &option);
 
 		if (c == -1 || c == EOF)
 			break;
@@ -252,6 +257,8 @@
 			exit (STATE_OK);
 		case '?':									/* help */
 			usage5 ();
+		case 'p':
+			perfdataonly = 1;
 		}
 	}
 
@@ -318,6 +325,8 @@
   printf ("    %s\n", _("the load average format is the same used by 
\"uptime\" and \"w\""));
   printf (" %s\n", "-r, --percpu");
   printf ("    %s\n", _("Divide the load averages by the number of CPUs (when 
possible)"));
+  printf (" %s\n", "-p, --perfdataonly");
+  printf ("    %s\n", _("Prints just performance data, ignores thresholds for 
warning and critical"));
 
 	printf (_(UT_SUPPORT));
 }


If -p is set at the call, the measured values are not compared with the 
thresholds, even no error is given if no thresholds are set. This is not in 
this patch, it is because the original code just checks if at least one 
parameter is given.

An other possibility would be to give no error if no thresholds or no 
parameter is given and just returns the measured values and a OK state.


>
>
> Greetings
> 	Christian



-- 
Christian Schneemann

-------------------------------------
SUSE LINUX Products GmbH,
Maxfeldstr. 5, D - 90409 Nürnberg

Phone:  +49 (0)911 - 740 53 0
e-mail: cschneemann at suse.de
-------------------------------------
SUSE LINUX Products GmbH, GF: Markus Rex
HRB 16746 (AG Nürnberg)




More information about the Devel mailing list