Revision: 1851
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1851&view=rev
Author: psychotrahe
Date: 2007-12-09 16:19:27 -0800 (Sun, 09 Dec 2007)
Log Message:
-----------
Fixed check_load argument handling when passing non triplet thresholds. Thanks to Jonathan Kamens (bug #1831890)
Modified Paths:
--------------
nagiosplug/trunk/NEWS
nagiosplug/trunk/plugins/check_load.c
nagiosplug/trunk/plugins/t/check_load.t
Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS 2007-12-09 23:36:26 UTC (rev 1850)
+++ nagiosplug/trunk/NEWS 2007-12-10 00:19:27 UTC (rev 1851)
@@ -15,6 +15,7 @@
implement stratum thresholds support (feature request #1703823).
Fix check_disk reporting OK if disk usage grows over 100% (bug #1348746).
The problem happens to be in Gnulib but a workaround have been implemented in check_disk.c
+ Fix check_load argument handling when not passing triplets (bug #1831890)
1.4.10 28th September 2007
Fix check_http buffer overflow vulnerability when following HTTP redirects
Modified: nagiosplug/trunk/plugins/check_load.c
===================================================================
--- nagiosplug/trunk/plugins/check_load.c 2007-12-09 23:36:26 UTC (rev 1850)
+++ nagiosplug/trunk/plugins/check_load.c 2007-12-10 00:19:27 UTC (rev 1851)
@@ -77,6 +77,7 @@
get_threshold(char *arg, double *th)
{
size_t i, n;
+ int valid = 0;
char *str = arg, *p;
n = strlen(arg);
@@ -84,12 +85,13 @@
th[i] = strtod(str, &p);
if(p == str) break;
+ valid = 1;
str = p + 1;
if(n <= (size_t)(str - arg)) break;
}
/* empty argument or non-floatish, so warn about it and die */
- if(!i) usage (_("Warning threshold must be float or float triplet!\n"));
+ if(!i && !valid) usage (_("Warning threshold must be float or float triplet!\n"));
if(i != 2) {
/* one or more numbers were given, so fill array with last
Modified: nagiosplug/trunk/plugins/t/check_load.t
===================================================================
--- nagiosplug/trunk/plugins/t/check_load.t 2007-12-09 23:36:26 UTC (rev 1850)
+++ nagiosplug/trunk/plugins/t/check_load.t 2007-12-10 00:19:27 UTC (rev 1851)
@@ -11,10 +11,11 @@
my $res;
-my $successOutput = '/^OK - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
-my $failureOutput = '/^CRITICAL - load average: [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+, [0-9]+\.?[0-9]+/';
+my $loadValue = "[0-9]+\.?[0-9]+";
+my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/";
+my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
-plan tests => 6;
+plan tests => 11;
$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
@@ -28,3 +29,9 @@
cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
like( $res->output, $failureOutput, "Output OK");
+$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
+cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
+like( $res->output, $successOutput, "Output OK");
+like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
+like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
+like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.